Answer the question
In order to leave comments, you need to log in
Laravel 5.6 - why is control not being transferred to the controller?
Immediately I enclose the code of the route, controller and view. Everything is as simple as possible, but, apparently, I do not understand something.
The task is to download the img file, which is in storage/app/public/uploads
Route::get('/download/{path}', '[email protected]')->name('download');
public function index()
{
return view('upload')->with(['path' => 'uploads/foo.jpg']);
}
public function download($path)
{
$file = storage_path($path);
dd($file);
return response()->download($file, 'filename.jpg')->deleteFileAfterSend(true);
}
<a href="{{route('download', ['path' => $path])}}" style="padding: 10px; border: 1px solid darkblue;">Скачать</a>
Answer the question
In order to leave comments, you need to log in
You need to add a slash to the pattern - https://laravel.com/docs/5.6/routing#parameters-re...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question