5

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

Maitray Suthar
  • 263
  • 2
  • 13
Dev Doc
  • 170
  • 3
  • 12
  • I have detected a thing that should really concern you. You shouldn't have your storage folder under /root since that is the root account's home folder, unless by root you mean the root folder of your Laravel application. – idelara Jun 14 '17 at 05:49
  • by root i mean the home folder of my laravel application – Dev Doc Jun 14 '17 at 06:07
  • Thank you,I've just created symbolic folder in the website root directory, its working fine for me :) – Dev Doc Oct 04 '17 at 09:08
  • I am glad it helped you! – idelara Oct 04 '17 at 16:51

3 Answers3

5

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';
})
marifyahya
  • 51
  • 1
  • 3
2

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

Bilawal Awan
  • 422
  • 3
  • 13
1

Please create link folder with storage folder that will create same folder in the project file library. For further information, Symbolic links using PHP

Adil Ansari
  • 346
  • 2
  • 13