I have a shared host, I only have access via Cpanel.
But I have a small problem, as uploaded images do not appear.
Does anyone know how to solve?
Code where I save the image
$request->picture->storeAs('public/upload/authors', $filename);
Code to see image
<img src="{{ asset('storage/upload/authors/'.$author->picture.'') }}" width="75" height="75">
Does anyone know what can it be??
3
Answers
I solved my problem this way. In the public folder, I created a file called
symlink.php
using the following code.I deleted the folder
storage
inpublic_html
and uploaded my.php
file inpublic_html
. Then I run the code through the domain accessing the domainexample.com/symlink.php
. Finally, the server creates a folder that is linked to the project's storage folder.Are you getting an error when trying to submit the form? Are you getting a 404 error when you surf to the supposedly uploaded picture? This sounds like the upload folder has insufficient permissions to store the uploaded pictures. Try setting the permissions of the upload folder to 775.
More info on CHMOD: http://www.stadtaus.com/en/tutorials/chmod-ftp-file-permissions.php
Check, if your uploaded Image is appearing under
/public/upload/authors
directorey use:<img src="{{ asset('upload/authors/'.$author->picture.'') }}" width="75" height="75">
If you uploaded image is appearing under
/storage/app/public/upload/authors
directory use:<img src="{{ Storage::get('public/upload/authors/'.$author->picture.'') }}" width="75" height="75">
P.S. Sorry I didn’t remember where exactly storeAs function is storing: in public or in storage 🙂
Note! asset() function is getting file urls from
app/public
folder, but Storage::get() is getting files fromapp/storage/app
folder