ajustement formulaire
This commit is contained in:
@@ -24,10 +24,35 @@ $titre = filter_var($_POST["titre"], FILTER_SANITIZE_STRING);
|
||||
$tag = filter_var($_POST["tag"], FILTER_SANITIZE_STRING);
|
||||
$promoteurice = filter_var($_POST["promoteurice"], FILTER_SANITIZE_STRING);
|
||||
$problematique = filter_var($_POST["problématique"], FILTER_SANITIZE_STRING);
|
||||
$resume = filter_var($_POST["résumé"], FILTER_SANITIZE_STRING);
|
||||
$description = filter_var($_POST["description"], FILTER_SANITIZE_STRING);
|
||||
$orientation = filter_var($_POST["orientation"], FILTER_SANITIZE_STRING);
|
||||
$ap = filter_var($_POST["ap"], FILTER_SANITIZE_STRING);
|
||||
$lien = filter_var($_POST["lien"], FILTER_SANITIZE_STRING);
|
||||
$couverture = $_FILES["couverture"];
|
||||
$files = $_FILES["files"];
|
||||
|
||||
// Transformation du string de mot-clé en un array.
|
||||
$tagArray = explode(', ', $tag);
|
||||
|
||||
|
||||
$coverFolder = $memoireFolder . "data/cover/";
|
||||
if (!file_exists($coverFolder)) {
|
||||
mkdir($coverFolder, 0755, true);
|
||||
}
|
||||
|
||||
$couverturePath = "";
|
||||
if ($couverture["error"] === UPLOAD_ERR_OK) {
|
||||
$fileExtension = pathinfo($couverture["name"], PATHINFO_EXTENSION);
|
||||
$newCouvertureName = $auteurice . "_" . $annee . "_" . $uniqueId . "." . $fileExtension;
|
||||
$targetFile = $coverFolder . $newCouvertureName;
|
||||
if (move_uploaded_file($couverture["tmp_name"], $targetFile)) {
|
||||
chmod($targetFile, 0644);
|
||||
$couverturePath = $targetFile;
|
||||
} else {
|
||||
error_log("Failed to move uploaded couverture file: " . $couverture["name"]);
|
||||
}
|
||||
}
|
||||
|
||||
$uploadedFiles = [];
|
||||
|
||||
// Create necessary directories
|
||||
@@ -47,9 +72,9 @@ $sanitizedAuteurice = Transliterator::transliterate($auteurice);
|
||||
$uniqueFileName = $sanitizedAuteurice . "_" . $date . "_" . $uniqueId;
|
||||
|
||||
// Define security constraints
|
||||
$allowedMimeTypes = ['image/jpeg', 'image/png', 'application/pdf'];
|
||||
$allowedExtensions = ['jpg', 'jpeg', 'png', 'pdf'];
|
||||
$maxFileSize = 5 * 1024 * 1024; // 5 MB
|
||||
$allowedMimeTypes = ['image/jpeg', 'image/png', 'application/pdf', 'video/mp4', 'application/zip'];
|
||||
$allowedExtensions = ['jpg', 'jpeg', 'png', 'pdf', 'mp4', 'zip'];
|
||||
$maxFileSize = 50 * 1024 * 1024; // 50 MB
|
||||
|
||||
// Process uploaded files
|
||||
if (is_array($files["name"])) {
|
||||
@@ -88,6 +113,7 @@ if (is_array($files["name"])) {
|
||||
error_log("Failed to move uploaded file: " . $files["name"][$i]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -97,12 +123,14 @@ $formData = [
|
||||
'année' => $annee,
|
||||
'email' => $mail,
|
||||
'titre' => $titre,
|
||||
'tag' => $tag,
|
||||
'tag' => $tagArray,
|
||||
'promoteurice' => $promoteurice,
|
||||
'problématique' => $problematique,
|
||||
'resume' => $resume,
|
||||
'description' => $resume,
|
||||
'orientation' => $orientation,
|
||||
'ap' => $ap,
|
||||
'lien' => $lien,
|
||||
'couverture' => $couverturePath,
|
||||
'files' => $uploadedFiles
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user