Ndroid21
Ndroid21

Reputation: 478

Laravel Symbolic Link not working

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.

Upvotes: 11

Views: 9900

Answers (3)

Nysh
Nysh

Reputation: 21

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

Upvotes: 2

sweetkaos
sweetkaos

Reputation: 361

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

rm public/storage
php artisan optimize:clear
php artisan storage:link

Upvotes: 17

Rohit shah
Rohit shah

Reputation: 819

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.

Upvotes: -2

Related Questions