if (!empty($_FILES)) { //Photo $check = checkOnePhoto("photo", 2097152, 1000, 1000, ['.jpg', '.jpeg', '.png'], NULL, PHOTO_EVENT); if ($check[0]) { $photo = $check[1]; } else { if ($check[1] != NULL) { $errors["photo"] = $check[1]; } } } } //Upload de la Photo if (empty($errors)) { if (!empty($photo) and $photo != -1) { $upload = uploadOnePhoto("photo", NULL, PHOTO_EVENT, $photo); if ($upload) { $push["lien_photo"] = $photo; } else { $errors["photo"] = "[Erreur Serveur - Contactez l'administrateur] Erreur dans la copie de la photo."; } } } // Insertion de l'event ou affichage de la vue avec les erreurs : if (empty($errors)) { /// INSERTION EN BDD : /// if ($id = insertEvent($push)) { alert('ok', 'Succès ! L\'évènement a bien été créé.'); header('Location: ' . getLink(['events', 'display', $id])); exit; } else {
} else { $_POST[$cle] = htmlspecialchars($_POST[$cle]); } } // Affiche les champs à jour avec ce qui a été saisi dans le formulaire. foreach ($_POST as $cle => $valeur) { $contents[$cle] = $valeur; } //Entrée BDD si pas d'erreurs : if (!empty($errors)) { $doIt = False; } else { $doIt = True; } if (!empty($photo) and $photo != -1 and $doIt == True) { $upload = uploadOnePhoto("photo", $contents["lien_photo"], PHOTO_PROFIL, $photo); if ($upload) { $contents["lien_photo"] = $photo; } else { $errors["photo"] = "[Erreur Serveur - Contactez l'administrateur] Erreur dans la copie de la photo."; $doIt = False; } } if (isset($photo)) { if ($photo == -1 and $doIt == True) { unlink(PHOTO_PROFIL . $contents["lien_photo"]); unset($contents["lien_photo"]); } } if ($doIt) { //Sécurisation par htmlspecialchars
// Si il veut supprimer la photo if (isset($_POST['photo']) && empty($errors)) { if ($_POST['photo'] == -1) { $photo = -1; $push["lien_photo"] = -1; var_dump($contents['values']["lien_photo"]); $push["old_lien_photo"] = $contents['values']["lien_photo"]; $contents['values']["lien_photo"] = -1; } } } } //Upload de la Photo if (empty($errors)) { if (!empty($photo) and $photo != -1) { $upload = uploadOnePhoto("photo", $contents['values']["lien_photo"], PHOTO_EVENT, $photo); if ($upload) { $push["lien_photo"] = $photo; } else { $errors["photo"] = "[Erreur Serveur - Contactez l'administrateur] Erreur dans la copie de la photo."; } } } if (!empty($_POST) && !empty($push)) { // Affiche les champs à jour avec ce qui a été saisi dans le formulaire. foreach ($push as $cle => $valeur) { $contents['values'][$cle] = $push[$cle]; } foreach ($nameTranslation as $cle => $value) { $contents['values'][$value] = $push[$cle]; }