We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Album Plugin redirect error 404 | Forum

Ted
Ted Aug 19 '11
Hello!

When done downloading photos, and if you do not put the album title is a redirect to a 404 page. At the same time, the picture remains on the server. Newbie can upload many photos ignoring the album title ..

I understand the problem in the execution of this code ? or my server settings? Album plugin version photo.4069, ow_1.2.3

                    echo "$album->name\t$album->id\n";
                }
            }
        }
        else
        {
            throw new Redirect404Exception();
            exit();

file ow_plugins/photo/controllers/upload.php line 393
Den Team
Den Aug 20 '11
Topic was moved from Plugins.
Myzik
Myzik Sep 30 '23


   In the code section where photos are uploaded without specifying an album title, add a condition to check if an album title is provided or not. You can do this..
Ex..

   ```php
   if (empty($_POST['album_title'])) {
       // Handle the case where the album title is missing
       // You can either display an error message or assign a default album title.
       $albumTitle = 'Default Album'; // Set a default album title
   } else {
       $albumTitle = $_POST['album_title'];
   }
   ```

Once you have determined the album title, you can create a new album or select an existing one with that title.

   Ex..

   ```php
   // Check if an album with the given title already exists
   $existingAlbum = yourAlbumLookupFunction($albumTitle);

   if ($existingAlbum) {
       // Use the existing album
       $albumId = $existingAlbum->id;
   } else {
       // Create a new album with the provided title
       $newAlbum = yourAlbumCreationFunction($albumTitle);
       $albumId = $newAlbum->id;
   }
   ```

   Now that you have the album ID, associate the uploaded photos with this album.

   Ex..

   ```php
   // Assuming you have an array of uploaded photo filenames
   $photoFilenames = $_FILES['photo']['name'];

   foreach ($photoFilenames as $filename) {
       // Upload the photo and associate it with the album
       yourPhotoUploadFunction($filename, $albumId);
   }
   ```
After successfully uploading and associating the photos with the album, you can decide whether to redirect the user to the newly created or selected album page or display a success message.

Ex..


   ```php
   // Redirect to the album page
   header('Location: /album/' . $albumId);
   exit();
   ```

Now you can handle situations where users upload photos without specifying an album title more gracefully and avoid the 404 error.

now Manually test use browser developer tools to inspect network requests and redirects or use any online tool like https://redirectchecker.com/  This can help you to get detail redirection chain and its status code.

The Forum post is edited by Myzik Sep 30 '23