skip to Main Content

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?

enter image description here

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


  1. Chosen as BEST ANSWER

    I solved my problem this way. In the public folder, I created a file called symlink.php using the following code.

    <?php
    
    symlink('/home/server_name/project_app_folder/storage/app/public', 
        '/home/server_name/public_html/storage');
    

    I deleted the folder storage in public_html and uploaded my .php file in public_html. Then I run the code through the domain accessing the domain example.com/symlink.php. Finally, the server creates a folder that is linked to the project's storage folder.


  2. 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

    Login or Signup to reply.
  3. 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 from app/storage/app folder

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search