OK, so here's my code. (I'll sanitize it later. Don't worry about it.)
<?php
include_once('../basics.php'); //Site configs
include_once('class.user.php'); //For storing user data and stuff
include_once('class.image.php');
include_once('auth.php'); // The user authenticator
// Check if user wants to upload to existing or new album
if (isset($_POST['album'])) {
if ($_POST['album'] == '') {
$_POST['album'] = $_POST['new_album'];
}
}
// Populate album dropdown menu
$albums = $database->query("SELECT DISTINCT(album) FROM images")->fetchAll(PDO::FETCH_COLUMN);
// Load the 'upload new photo' interface if user's not uploading it already
if (!isset($_FILES['image_link']) || !isset($_POST['caption']) || $_POST['caption'] == '') {
//var_dump($_FILES);
//var_dump($_POST);
include('views/gallery_upload_new.php');
// Otherwise store the image file, register it into database, and put the user back in the list of photos
} else {
$new_image = new Image($_POST['caption'], $_POST['album']);
$new_image->register($_FILES['image_link']['tmp_name'], $_FILES['image_link']['name']);
header('location: gallery_management.php');
}
?>
Here's the weird part: without those two var_dump
's up there, the else
block won't execute. I've made sure the indexes in the $_POST
and $_FILES
are correct. Yet without those dummy dumps, this thing won't work. It doesn't even matter if they're commented out or not. They just need to be there.
What did I do wrong? Did I made a syntax error somewhere?
Aucun commentaire:
Enregistrer un commentaire