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
Fatal Error: Call to Undefined Function Sqlsrv_Connect()
Laravel Storage Link Won't Work on Production
How to Change Default Url from Localhost:8000 to Other Ip in Laravel When We Run "Php Artisan Serve"
Convert HTML Form Data into a Pdf File Using PHP
Codeigniter: Fatal Error Call to Undefined Function Mysqli_Init()
Sum Values from Column in HTML
Session Destroy When One Browser Tab Gets Closed
Mongodb Updating Fields in Nested Array
How to Insert Md5 Hash Value in Ms SQL Server
Generating a Truly Unique Order Id in PHP
Laravel Eloquent Get Results Grouped by Days
My Routes Are Returning a 404, How to Fix Them
How to Set Variables in a Laravel Blade Template
Openssl Ssl_Read: Ssl_Error_Syscall, Errno 104
What Does the PHP Error Message "Notice: Use of Undefined Constant" Mean
Call PHP Function from JavaScript
Regex for Only Allowing Letters, Numbers, Space, Commas, Periods