Laravel Storage Link Won't Work on Production

Laravel storage link won't work on production

SOLVED

Thanks for all your helps, I tried to run php artisan storage:link on my server and I found out that my server has disabled symlink for security reason.

So I have changed all my image uploading functions to upload images in my public folder instead of storage folder and now everything is working just fine.

Laravel Cannot Access Image Stored in Storage Folder after Uploading in Server

The href will be correct, but that's not the issue. The issue is the presence of the file at the location of the link. It's not there, as you're finding.

When you upload, make sure you are not uploading a real directory at public/storage.

On your local server, did you, by mistake, create a real directory at public/storage?

If you did, you need to know that the laravel convention is to store your files in the storage/app/public directory in your app directory.
You don't create the folder public/storage yourself.
You create a symlink to link it to there instead. That way, stuff you put in storage/app/public, also appears, because of the symlink, at public/storage.

First check your local server follows the laravel convention outlined above (and in the docs), then, after uploading to your server, try the storage:link command again, and, so long as you don't have a real directory at public/storage anymore, but just a link, it should hopefully work.

Note what I've done here is interpret the error message you were getting about that directory already existing.

Also, check this answer if you are using Homestead. Instead of creating a storage link on the host computer, you should ssh into Vagrant and create a storage link here.

How to create laravel storage symbolic link for production or sub domain system?

I solved this problem by another command for creating a symbolic link by terminal/cmd/shh:

ln -s /path/to/laravel/storage/app/public /path/to/public/storage

I solved this also Using laravel web route routes/web.php

Route::get('/foo', function () {
Artisan::call('storage:link');
});

Symbolic link not working in Laravel and image not loading

If you have no ssh/terminal access, then create symbolic link with Route, run it once & delete it.

route/web.php :

Route::get('/sym', function () {
Artisan::call('storage:link');
});

Hope this helps

Laravel - Image saved in storage folder not showing to user

Laravel storage filesystem is so unique. When you doing any upload it will upload in the storage/app/public directory. To make it accessible in public directory, things need to do is create symlink by run command:

php artisan storage:link

This command will symlinked storage/app/public to public/storage

Just follow the documentation about how to put and how to retrieve the file url. I am pretty sure the step you are missing is creating the symlink.

Hope it helps.



Related Topics



Leave a reply



Submit