skip to Main Content

I have a problem displaying images when hosting the site. Locally, I was using the dynamic link to display images, but it only works locally. My images are stored in the : : storage/app/public/Images tree.

<div class="card-bg" style="background-image: url('{{ asset('storage/ServiceImages/' .$service->service_image) }}');" ></div>

and this

<img src="/storage/ActualityImages/{{$actualite->actuality_image}}" class="img-fluid" alt="" style="height: 200px; object-fit: cover;">

Using both approaches the images are displayed locally but not online. and I’m asked to use the absolute path, I’ve done so but without success.

2

Answers


  1. Chosen as BEST ANSWER
            $image = $request->file('service_image');
            $imageName = time() . '.' . $image->getClientOriginalExtension();
            $image->StoreAs('public/ServiceImages', $imageName);
    

    the way i record my images


  2. You can delete the Storage folder
    And run this again on your server

    Php artisan storage:link 
    

    However if you don’t have SSH access to the Terminal

    You can store the public files in the **public folder without any symlinks

    Here’s how u can do it

    In filesystems.php
    

    Change this code

    'root' => storage_path('app/public'), 
            'url' => env('APP_URL').'/storage', 
           
    

    With this

    'root' => public_path(), 
     'url' => env('APP_URL'), 
    

    An then u access you image

    https://yourwebsite.com/ActualityImages/$imagename

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