Update file upload.php

This commit is contained in:
Jan BELLON 2024-03-07 02:30:54 +00:00
parent 3e2f2e3964
commit 7c1125524d

View File

@ -11,6 +11,9 @@ if(isset($_POST['titre'])) {
$filename = rand(100000, 999999);
$destination = "../content/journal/" . $filename . ".md";
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $destination)) {
die("Le fichier n'a pas pu être téléchargé.");
}
$upload = $bdd->prepare("INSERT INTO articles (ID, titre, date, auteur) VALUES (:filename, :titre, :date, :auteur)");
$upload->bindParam(':filename', $filename);
$upload->bindParam(':titre', htmlspecialchars($_POST['titre']));
@ -23,10 +26,8 @@ if(isset($_POST['titre'])) {
if($upload->execute()) {
$status = "Uploaded";
} else {
$status = "Error";
$status = "SQL Error";
}
move_uploaded_file($_FILES['file']['tmp_name'], $destination);
}
?>