From 949737cf5fc2a21b36c4a269a437d0dc2e965441 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 9 Feb 2024 15:56:55 +0100 Subject: 1er commit --- photospolo/photoupload.php | 90 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 photospolo/photoupload.php (limited to 'photospolo/photoupload.php') diff --git a/photospolo/photoupload.php b/photospolo/photoupload.php new file mode 100644 index 0000000..c3a2079 --- /dev/null +++ b/photospolo/photoupload.php @@ -0,0 +1,90 @@ +prepare('INSERT INTO photospolo (nomphoto) VALUES (:nom)'); + $requête->execute(array('nom' => $nom)); + + $requête->closeCursor(); + + // changer le nom de la photo sélectionnée dans le fichier photo.txt + $fichier = fopen('photo.txt','r+'); + ftruncate($fichier,0); // évite les problèmes quand on change pour un nom plus court + fputs($fichier, $nom); + fseek($fichier, 0); + fclose($fichier); + + header('Location: ../administration.php?modifphoto=4'); // succès, move_uploaded_file renvoie la valeur TRUE + exit (); + } + else // echec à l'enregistrement, la fonction renvoie FALSE + { + header('Location: ../administration.php?modifphoto=3'); + exit (); + } + } + else // mauvais format + { + header('Location: ../administration.php?modifphoto=2'); + exit (); + } +} +else // mauvaise taille +{ + header('Location: ../administration.php?modifphoto=1'); + exit (); +} + +?> -- cgit v1.2.3