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
Following the answer of @Abdula Nilam I got the following error:
I assume is because of permissions of the storage folder.
I fixed it with:
After this I got my app working correctly.
I’m not sure, certainly. As a wild guess, check your permission since you say it worked on another project.