66 lines
2.9 KiB
PHP
Executable File
66 lines
2.9 KiB
PHP
Executable File
<?php
|
|
$nomFicAppelant = basename(__FILE__);
|
|
// -----------------------------------------------------
|
|
// Cartouche
|
|
// -----------------------------------------------------
|
|
// auteur : eric
|
|
// datemaj : 20/11/2020
|
|
// fonction : uploader image, ico, ...
|
|
// algo : bouton parcourir
|
|
// algo : submit / post
|
|
// algo : verif de tmp_name et du fichier [ici]
|
|
// algo : requete update => theFichier =>codeOpe:upIco / puis select
|
|
// flag edt : gerer le upload_max_filesize MAX_FILE_SIZE https://www.php.net/manual/fr/features.file-upload.errors.php
|
|
|
|
// -----------------------------------------------------
|
|
// Upload
|
|
// -----------------------------------------------------
|
|
$target_dir = "../Design/_icones_web/";
|
|
$target_file = $target_dir.basename($_FILES['fileToUpload' .$theIDLg]['name']);
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['fic=' => $_FILES["fileToUpload", 'theIDLg]["name"]' => $theIDLg]["name"]], '');}
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['fic tmp=' => $_FILES["fileToUpload", 'theIDLg]["tmp_name"]' => $theIDLg]["tmp_name"]], '');}
|
|
$uploadOk = 1;
|
|
|
|
|
|
// Check if image file is a actual image or fake image sauf SVG
|
|
$check = getimagesize($_FILES["fileToUpload" .$theIDLg]["tmp_name"]);
|
|
if ($check !== false) {
|
|
$admMsg .= "<br>Votre fichier convient. ";
|
|
$uploadOk = 1;$admMsgClass='ok';
|
|
}
|
|
else {
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Votre fichier ne convient pas -' => $check["mime"]], '');}
|
|
$uploadOk = 0; $admMsgClass='ko';
|
|
}
|
|
|
|
// Allow certain file formats
|
|
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
|
|
if ($imageFileType != "gif" && $imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "bmp") {
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['imageFileType' => $imageFileType], '');}
|
|
$uploadOk = 0; $admMsgClass='ko';
|
|
}
|
|
|
|
// Check if $uploadOk is SET to 0 by an error
|
|
if ($uploadOk == 0) {
|
|
$admMsg .= "Désolé, fichier non chargé. ";
|
|
}
|
|
else {
|
|
if (move_uploaded_file($_FILES["fileToUpload" .$theIDLg]["tmp_name"], $target_file))
|
|
{
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Le fichier' => '', 'fileToUpload' => $theIDLg]["name"])], '');}
|
|
// cette page n'est pas à la cible en profondeur, on corrige la profondeur, on la remettra la profondeur pour affichage
|
|
$test=str_replace("../../","./",$target_file);
|
|
$target_file=$test;
|
|
$theFichier= $target_file;
|
|
// $codeOpe='upIco';
|
|
$uploadOk = 1;
|
|
$admMsgClass='ok';
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Upload = OK' => ''], '');}
|
|
}
|
|
else
|
|
{
|
|
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Désolé, il y a eu une erreur en chargeant votre fichier' => ''], '');}
|
|
$uploadOk = 0;
|
|
}
|
|
}
|
|
?>
|