I've created symbolic link at local PC, where its working fine, but I've uploaded same it to shared hosting, it is not working there.
Basically I've images in the storage folder root/storage/public/images/
i want to display them by getting
$path=asset('storage/images/'.$item->image);
so the problem is in the shared hosting this way
$path=asset('storage/images/'.$item->image);
getting from the domain directory not from the parent directory, so for that there is no way to create symbolic link on shared hosting so what should I do to get images from the parent directory. I am beginner in laravel one can help me to solve this problem. Thanks
first delete folder storage from folder public and, using this code in web.php
Route::get('foo', function(){
$targetFolder = $_SERVER['DOCUMENT_ROOT'].'/project_foder/laravel/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/project_foder/public/storage';
symlink($targetFolder, $linkFolder);
return 'success';
});
or
Route::get('foo', function(){
Artisan::call('storage:link', []);
return 'success';
})
I got this a solution here
first, delete the public/storage {storage} folder Second, put this code in the top of the web.php file
Artisan::call('storage:link');
this code runs the php artisan storage:link command manually
Please create link folder with storage folder that will create same folder in the project file library. For further information, Symbolic links using PHP
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With