5000000) { log_activity($userId, 'Image Upload Failed', 'User ' . $username . ' attempted to upload too large file: ' . $original_filename); header('Location: gallery.php?error=file_too_large'); exit(); } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { log_activity($userId, 'Image Upload Failed', 'User ' . $username . ' attempted to upload invalid format: ' . $original_filename); header('Location: gallery.php?error=invalid_format'); exit(); } // Try to upload file if (move_uploaded_file($_FILES["imageFile"]["tmp_name"], $target_file)) { log_activity($userId, 'Image Uploaded', 'User ' . $username . ' uploaded image: ' . $original_filename); header('Location: gallery.php?success=upload'); } else { log_activity($userId, 'Image Upload Failed', 'User ' . $username . ' failed to upload image: ' . $original_filename); header('Location: gallery.php?error=upload_failed'); } } else { header('Location: gallery.php'); } ?>