6

I have some problems creating a symbolic link with laravel to access files that are in my storage

I am storing my files in storage\app\public

I used the php artisan command to create the link php artisan storage: link The [public/storage] directory has been linked.

Earlier files were storing in storage\app\public and were also visible in public\storage folder

But now they are only storing in storage\app\public and not visible in public\storage folder

I am using link to show file path {{ Storage::url($package->reportPath['path']) }} Path is showing correct but it redirect to 404 page as there is no file I guess.

Ndroid21
  • 400
  • 1
  • 8
  • 19

3 Answers3

12

This solved it for me on laravel 8, hosted on a ec2 server.

rm public/storage
php artisan optimize:clear
php artisan storage:link
sweetkaos
  • 311
  • 3
  • 6
0

Try removing your public/storage directory and try running storage:link again. This worked for me.

Nysh
  • 1
  • 1
-1

If you are trying to Show the stored file use asset()

asset('storage/further_path/').$file_name;

To store file you can do

$destinationPath = storage_path('app/public/further_path'); 
if (!is_dir($destinationPath)) {
    mkdir($destinationPath, 0777, TRUE); 
} 
$request->file->move($destinationPath,$filename);

Hope this Helps You.

Let me Know if You have any problem.

Rohit shah
  • 833
  • 4
  • 15