1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
$SoundName_bak=""; if(!empty($_POST["SoundName_bak"]))
$SoundName_bak=addslashes($_POST["SoundName_bak"]);
if($_FILES['fichierSON']['size']>80000000)
{
$alerte = 'Votre fichier son dépasse la limite autorisée (80 Mo) !\n';
echo "<script type=\"text/javascript\">alert(\"$alerte\");</script>";
exit;
}
else {
//on remplace les caractères spéciaux du nom du fichier par des caractères standards
$search = array ('@[ËÊÈÉéèëê]@i','@[ÄÂÀÁäâàá]@i','@[ÏÎÌÍïîìí]@i','@[ÜÛÙÚüûùúµ]@i','@[ÖÔÒÓöôòó]@i','@[ç]@i','@[ñ]@i','@[ \'"]@i');
$replace = array ('e','a','i','u','o','c','n','_');
$_FILES['fichierSON']['name'] = preg_replace($search, $replace, $_FILES['fichierSON']['name']);
$Statut_corpus=""; if(!empty($_POST["Statut_corpus"]))
$Statut_corpus=addslashes($_POST["Statut_corpus"]);
$NomFichierSource ="";
if(!empty($_POST["NomFichierSource"]))
$NomFichierSource =addslashes($_POST["NomFichierSource"]);
$NomFichierSource = strtolower($NomFichierSource);
$NomFichierSource = ucfirst($NomFichierSource);
$rep = "../Corpus/$NomFichierSource/$Statut_corpus/";
//if(!is_dir($rep1))mkdir($rep1);
if(!is_dir($rep))mkdir($rep);
//si upload SON
if($_FILES['fichierSON']['size']>0){
$NewNameSON = $_FILES['fichierSON']['name'];
$fileSoundToUpload = $rep.$NewNameSON;
$filenameSound_bak = "../Corpus/$NomFichierSource/$Statut_corpus/$SoundName_bak";
$filenameSound_new = "../Corpus/$NomFichierSource/$Statut_corpus/$today-$SoundName_bak";
//si le fichier existe
if(file_exists($fileSoundToUpload)){
copy($filenameSound_bak, $filenameSound_new);
$ValidationSON = (move_uploaded_file($_FILES['fichierSON']['tmp_name'],$fileSoundToUpload));
}
//sinon on renomme l'ancien
else{
rename($filenameSound_bak, $filenameSound_new);
$ValidationSON = (move_uploaded_file($_FILES['fichierSON']['tmp_name'],$fileSoundToUpload));
//mise a jour nom fichier dans la table
$sqlUpdSON = " UPDATE header_tei SET SoundName = '$NewNameSON' WHERE id_fiche = '$id_fiche' " ;
$queryUpdSON = mysql_query($sqlUpdSON);
}
}
} |
Partager