Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel symlink and cPanel

On my Laravel website I'm using symlink to store and show the images from storage.

With

php artisan storage:link

I had created the symlink and everytime when I upload a new news article, the image is uploaded in the main Storage and with symlink it's setup to the public folder and I'm displaying the image properly.

So far so good, but when I've created a copy of the website, a problem appears...

When I've created a copy of the website with cPanels File Manager, and move to a new location, the storage symlink in the public directory has become a folder, not a symlink. After that when I try to upload a new news article, I can see it's uploaded in the main Storage folder, but not in the public/storage, so as a result the image is not displaying. That's because it's not a symlink anymore, but now it's a folder.

I've deleted the storage folder from the public directory, with SSH I've used the command again

php artisan storage:link

and I've created a new news article and the image is displaying properly, but now all other images are gone.

Is there any command that will regenerate the paths, so all other images will be display again?

I'm using Laravel 5.5

like image 558
user2519032 Avatar asked Jan 18 '26 11:01

user2519032


1 Answers

Try this:

In route/web.php add the following code:

Route::get('/storage', function(){
    \Artisan::call('storage:link');
    return "Se han vinculado las imágenes";
});
like image 148
Brayan Angarita Avatar answered Jan 21 '26 07:01

Brayan Angarita



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!