Reputation: 321
I have a problem with symlink. after I run this command php artisan storage:link
the uploaded images are showing in the public and storage folder.
I can display my img by using this code
<img src="{{ url('/storage/app/public/Attachments/test.png') }}" alt="">
but after a day the shortcut of the images folder in public has gone and when I run the php artisan storage:link
it says it has been already linked.
my problem now is i cannot display the images.
i saw a similar question but it doesn't work for me. please help guys. thanks and staysafe.
Upvotes: 2
Views: 3473
Reputation: 567
This happens if you are moving the project from one computer to another. When you copy the folders over to another machine, it sees the symlink
folder as just another folder. So when you run php artisan storage:link
it will just say that you already have the symlink
created but your files won't display because the shortcut to folder
or symlink
does not actually exist.
Solution:
What you need to do is go to your public folder and delete the storage folder. Then run the php artisan command again and your problem will be solved.
Upvotes: 4
Reputation: 455
create a .php
file in your public folder and put the following code and then visit the .php
page from your web browser
<?php
$target = '../storage/app/public';
$shortcut = '/storage';
symlink($target, $shortcut);
?>
now your public/storage
folder will lead to /storage/app/public
Upvotes: 0