'download file from the storage in laravel
i have laravel app, and i have a problem to make a storage link in the Hostinger, i tried everything and still not working,, so now I nedd to download files directly from (storage) in my rool laravel path not in public folder, how can I do that, I tried this code:
@if(is_file(storage_path('app'). '/public/user_files/files/' . $user->files))
<strong> <a href="{{ 'storage/app/public/user_files/files/'.$user->files }}">Download</a></strong>
for the code above i have accessed the files in the storage, but I couldn't download it, show me this error:
404 not found
Solution 1:[1]
@if(is_file(storage_path('app'). '/public/storage/user_files/files/' . $user->files))
<strong> <a href="{{ asset('storage/user_files/files/'. $user->files) }}">Download</a></strong>
Solution 2:[2]
1st you can run this command
php artisan storage:link
you can use this path inside the assest()
@if(is_file(storage_path('app'). '/public/storage/user_files/files/' . $user->files))
<strong> <a href="{{ asset('storage/app/public/user_files/files/'. $user->files) }}">Download</a></strong>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |
