skip to Main Content

I’m currently uploading 2 projects into my ubuntu server with cyberpanel. (One of them is https://simplycar.es/storage/fotos/1677542768-WhatsApp%20Image%202023-02-28%20at%2001.03.28.jpeg)

Both are in Laravel and use the same way to upload images.

Way to upload:

if (is_uploaded_file($request->file('foto'))) {
        $picture = time() . "-" . $request->file('foto')->getClientOriginalName();
        $request->file('foto')->storeAs('public/fotos', $picture);
    }

I already have another project running with the same structure to upload pictures, and it works correctly (https://chaincapitals.com/storage/logos/1669744070-C5l3mHJg_400x400.png).

But these two new projects don’t work with the uploaded images. They don’t appear in the URL (app. URL/(image-name)) and they don’t show on the website.

I’m writing the route of the images as I always do it:

{{asset('storage/fotos/'. AppModelsImage::where('idCar' , $car->id)->first()->imagen)}}

The storage link is working because, in my FTP App, it appears.

I tried to regenerate the symlink also generate it from a .PHP file.

Also, I tried with permissions things, I try this two things:

chmod -R o+w storage
chmod -R o+w bootstrap/cache

Also, I triod some other commands I saw on other topics.

2

Answers


  1. Chosen as BEST ANSWER

    Following the answer of @Abdula Nilam I got the following error:

    The stream or file "/home/simplycar.es/public_html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream:

    I assume is because of permissions of the storage folder.

    I fixed it with:

    sudo chmod -R ugo+rw storage
    

    After this I got my app working correctly.


  2. I’m not sure, certainly. As a wild guess, check your permission since you say it worked on another project.

    sudo chown -R www-data:www-data storage/
    sudo chmod -R 775 storage/
    
    # finally 
    php artisan cache:clear
    php artisan config:clear
    php artisan route:clear
    php artisan view:clear
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search