I have a Laravel 6.0 application where users can upload files to a server and it stores in the storage file system of laravel
. The system I'm using has been working in an older Laravel 5.6 project.
The link the Controller gives me:
domainame.com/public/file?folder=foldername&file=1569323440filename.png
Controller
public function getFile($foldername, $filename)
{
$fullpath = "app/{$foldername}/{$filename}";
return response()->download(storage_path($fullpath), null, [], null);
}
public function getFilesubfolder($foldername, $subfolder, $filename)
{
$fullpath = "app/{$foldername}/{$subfolder}/{$filename}";
return response()->download(storage_path($fullpath), null, [], null);
}
View
{{ route('file.show' ,['folder' => 'empresas' , 'file' => $factura->archivo])}}
The error I get is a 404 error because the link is trying to access doesn't exist. In my previous project the link was something like this:
domainame.com/public/folder/file
I created a symlink to the storage system. Am I missing another type of configuration or something?
I have solved my error, want to post the solution here if people come from a google search or something else:
My error was that starting in Laravel 6.0, the variables routes MUST be literal.
In my case I changed this:
{{ route('file.show' ,['folder' => 'empresas' , 'file' => $factura->archivo])}}
To this:
{{ route('file.show' ,['foldername' => 'empresas' , 'filename' => $factura->archivo])}}
I broke my mind because I was not seeing that error, hope it helps to anyone that is in my situation