0

I have a laravel project that i hosted on a shared host. using the system i saw on Laravel Deploy Instruction

So am suppose to upload image, -- user's image. To the public_html folder but since am not in the public_html so the users can't upload their image. since my code lie out side the public_html folder and it doesn't allow write permission for general users. so i tried uploading it to 'storage folder' (ie the my laravel project folder, that is in the sane level as the www 'public_html' folder.) it works i can see the image in the storage folder but i cant access because it is behind the public_html folder. and whatever can't be point to. Example project/storage/app/public is the folder that has the user image if i point to it in <img src="project/storage/app/public/user.png" > it wont display because the browser looks for project/storage/app/public inside the public_html folder whereas it is outside the public_html. So can someone touch on this. Thanks guys. Or is htaccess use in this case?

dagogodboss
  • 483
  • 1
  • 4
  • 19
  • I'll say the same thing I say on every Laravel shared hosting question... ditch the shared hosting. A VPS on Digital Ocean is $5/month. There's no reason to put yourself through the pain of shared hosting for a complex app like Laravel. – ceejayoz Apr 28 '17 at 13:49
  • Possible duplicate of [Laravel 5 - How to access image uploaded in storage within View?](http://stackoverflow.com/questions/30191330/laravel-5-how-to-access-image-uploaded-in-storage-within-view) – gabe3886 Apr 28 '17 at 13:54
  • Thanks I think that should do it – dagogodboss Apr 28 '17 at 14:32

2 Answers2

0

you need to create symlink to Your storage folder .

please see this answer:

Laravel 5 - How to access image uploaded in storage within View?

Community
  • 1
  • 1
Mortada Jafar
  • 3,529
  • 1
  • 18
  • 33
  • `Route::get('/storage-link', function() { $exitCode = Artisan::call('storage:link'); return '

    The [public/storage] directory has been linked.

    '; });` to run it with route on your browser
    – dagogodboss Apr 28 '17 at 14:59
  • How ever this doesn't create the symlink on my shared host – dagogodboss Apr 28 '17 at 15:00
0

the above method given by the link works for offline however not all shared hosting site support artisan Laravel sysmlink. so the absolute and best way to do this is with php symlink() function From PHP MANUAL

so just add this code to your web.php ie project\route\web.php

Route::get('/symlink', function()
{
    if(symlink('/home/username/projectfolder/storage/app/public', '/home/username/public_html/storage')){
    echo "We rock yea stackoverflow!!!! best programming software";}
});

so the username is the name of your home dir

dagogodboss
  • 483
  • 1
  • 4
  • 19