Paul Iverson Cortez
Paul Iverson Cortez

Reputation: 321

Laravel 8: Symbolic Link not appearing in public

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

Answers (2)

max234435
max234435

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

Themodmin
Themodmin

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

Related Questions