php - Laravel 8 404 not found when downloading pdf file from public folder
one text
I'm trying to download a pdf file from public/storage/files. However, I get 404 not found error.
Here's my route:
Route::get('/my_journeys/{slug}/download', 'Site\JourneyController@downloadFile')->name('journey.download');
Controller:
function downloadFile($file_name){
return response()->download(public_path('/storage/app/files/'.$file_name));
}
View file:
<table class="table" id="land_table">
<thead>
<tr>
<th scope="col">Isvykimo laikas</th>
<th scope="col">Grizimo laikas</th>
<th scope="col">Keliones pradzia</th>
<th scope="col">Keliones pabaiga</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ $journey->start_time }}</th>
<td>{{ $journey->end_time }}</th>
<td>{{ $journey->start_point }}</th>
<td>{{ $journey->end_point }}</th>
<td>{{ str_replace("public/files/","",$journey->path) }}</th>
<?php $val = str_replace("public/files/","",$journey->path); ?>
<td><button><a href="{{ route('journey.download', $val) }}" >Atsisi??sti </a></button></th>
<td><button><a href="{{ route('journey.pdf', $journey->slug) }}">Atsisi??sti PDF fail?�</a></button></td>
</tr>
</tbody>
</table>
What am I doing wrong? Any help would be greatly appreciated!
Source