par
yllan » 16 sept. 2010, 14:49
je l ai rajouter avant la fonction de l upload... mais ca ne donne rien...
peut etre m y suis je mal pris...
voila un bout du code si ca peut aider... en tout cas merci pour ton aide :
<?php
$destination = "../photo/";
function upload($index,$destination,$maxsize=FALSE,$extensions=FALSE)
{
//Test1: fichier correctement uploadé
if (!isset($_FILES[$index]) OR $_FILES[$index]['error'] > 0) return FALSE;
//Test2: taille limite
if ($maxsize !== FALSE AND $_FILES[$index]['size'] > $maxsize) return FALSE;
//Test3: extension
$ext = substr(strrchr($_FILES[$index]['name'],'.'),1);
if ($extensions !== FALSE AND !in_array($ext,$extensions)) return FALSE;
//Déplacement
return move_uploaded_file($_FILES[$index]['tmp_name'],$destination);
}
//EXEMPLES
mkdir("../photo/$dossier", 777);
$upload1 = upload("photo01","../photo/$dossier/$photo1",10485760, array('png','gif','jpg','jpeg') );
$upload2 = upload("photo02","../photo/$dossier/$photo2",10485760, FALSE );
?>
je l ai rajouter avant la fonction de l upload... mais ca ne donne rien...
peut etre m y suis je mal pris...
voila un bout du code si ca peut aider... en tout cas merci pour ton aide :
<?php
$destination = "../photo/";
function upload($index,$destination,$maxsize=FALSE,$extensions=FALSE)
{
//Test1: fichier correctement uploadé
if (!isset($_FILES[$index]) OR $_FILES[$index]['error'] > 0) return FALSE;
//Test2: taille limite
if ($maxsize !== FALSE AND $_FILES[$index]['size'] > $maxsize) return FALSE;
//Test3: extension
$ext = substr(strrchr($_FILES[$index]['name'],'.'),1);
if ($extensions !== FALSE AND !in_array($ext,$extensions)) return FALSE;
//Déplacement
return move_uploaded_file($_FILES[$index]['tmp_name'],$destination);
}
//EXEMPLES
mkdir("../photo/$dossier", 777);
$upload1 = upload("photo01","../photo/$dossier/$photo1",10485760, array('png','gif','jpg','jpeg') );
$upload2 = upload("photo02","../photo/$dossier/$photo2",10485760, FALSE );
?>