Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

knached99's avatar

Uploaded Images in Hostinger shared hosting are not being displayed

I have a Laravel 11 app deployed to Hostinger shared webhosting. The images are not being displayed at all and are returning a 404. One of the links is https://viveaventuras.net/destination/san-juan-puerto-rico where the image returns a 404. in my config/filesystems.php, I've ensured that the root for my public disk, is pointing to the public_html in the shared hosting, like so:

the images get saved here: /home/u664706382/domains/viveaventuras.net/public_html/storage/app/public/booking_photos but aren't being loaded properly.

Here's the Livewire Backend code responsible for uploading the images:

    if (!empty($this->tripPhotos) && is_array($this->tripPhotos)) {
                        \Log::info('User selected new pictures for upload. Iterating over new pictures..');
                        
                        foreach ($this->tripPhotos as $photo) {
                            \Log::info('Checking if user selected pictures');

                            if ($photo instanceof \Livewire\Features\SupportFileUploads\TemporaryUploadedFile) { 
                                $image = $photo->getRealPath();
                                $fileName = $photo->hashName() . '.' . $photo->extension();
                                // $filePath = 'booking_photos/' . $fileName;
                                // $fullPath = storage_path('app/public/' . $filePath);
                                $filePath = 'booking_photos/'.$fileName; 

                                $storagePath = Storage::disk('public')->path($filePath);
                              //  \Log::info('Resizing Image...');
                              //  Helper::resizeImage($image, $fullPath, 525, 351);
                    
                                // Save the image to the file system
                                $photo->storeAs('booking_photos', $fileName, 'public');
                          
                                $imageURLs[] = asset(Storage::url($filePath)); 
                                $imagesArray[] = $fileName; 
                                \Log::info('Current image URLs array: ' . json_encode($imageURLs));
                                \Log::info('Current images in the array: ' . json_encode($imagesArray));
                            }
                        }
                        
            
                    }

The photos get saved in the DB like so:

 $tripModel->tripPhoto = json_encode($imagesArray);
$tripModel->save();

on the front-end, here are how the images are displayed on the /destination/{destination-slug} page:

0 likes
1 reply

Please or to participate in this conversation.