Laravel shared hosting app, storage symbolic folder

I created a symbolic link on my local PC where it works fine, but I uploaded it to shared hosting it doesn't work there. Basically I have images in storage folderroot/storage/public/images/

I want to show them by receiving

$path=asset('storage/images/'.$item->image);

      

so the problem is shared hosting this way

$path=asset('storage/images/'.$item->image);

      

get from the domain directory not from the parent directory, so there is no way for this to create a symbolic link on shared hosting for me to do to get images from the parent directory. I am a beginner in laravel, I can help solve this problem. thank

+4


source to share


4 answers


Create a folder with a storage folder in which the same folder in the project file library will be created. For more information, Symbolic Links Using PHP



+1


source


I have the same problem and this article helps me. I created a symlink with SSH access, but it can also work with Cpanel's CronJob utility.



0


source


first remove the store folder from public folder 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';
})

      

0


source


I got this solution here

first, delete the public / storage {storage} folder. Second, place this code at the top of your web.php file.

Artisan::call('storage:link');

      

this code runs php artisan storage: link command manually

0


source







All Articles