$dst_h) $dst_w = $test_w; else $dst_h = $test_h; // Crée une image vierge aux bonnes dimensions $dst_im = imagecreatetruecolor($dst_w,$dst_h); // Copie dedans l'image initiale redimensionnée if ( $ext == ".jpg"){ $src_im = imagecreatefromjpeg($img_src); imagecopyresampled($dst_im,$src_im,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h); // Sauve la nouvelle image ImageJpeg($dst_im,$img_dest); } if ( $ext == ".gif"){ $src_im = imagecreatefromgif($img_src); imagecopyresampled($dst_im,$src_im,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h); Imagegif($dst_im,$img_dest); } if ( $ext == ".png"){ $src_im = imagecreatefrompng($img_src); imagecopyresampled($dst_im,$src_im,0,0,0,0,$dst_w,$dst_h,$src_w,$src_h); Imagepng($dst_im,$img_dest); } // Détruis les tampons ImageDestroy($dst_im); ImageDestroy($src_im); } /************************************************************************************************ ' REDIMENSIONNE IMAGE ************************************************************************************************/ /************************************************************************************************ ' GENERATION D'UN NOM ************************************************************************************************/ function un_nom($size){ $key_g = ""; $letter = "abcdefghijklmnopqrstuvwxyz"; $letter .= "0123456789"; srand((double)microtime()*date("YmdGis")); for($cnt = 0; $cnt < $size; $cnt++) { $key_g .= $letter[rand(0, 35)]; } return $key_g; } /************************************************************************************************ ' GENERATION D'UN NOM ************************************************************************************************/ ?> Untitled Document
"; if(is_dir($thedir)){ ######################################################################################### //#### ON VA COMPTER LE NB DE PHOPTOS DEJA UPLOADEES ######################################################################################### $dir = opendir($thedir) ; $h = 1; while ($f = readdir($dir)) { if( (is_file($thedir.$f)) && (substr($f,0,4)!='mini') && (substr($f,0,4)!='micr') ) { ######################################################################################### //#### SI SUPPRESSION DUNE PHOTO ######################################################################################### if($_GET[dell]==$f){ unlink($thedir.$f);unlink($thedir."/mini_".$f);unlink($thedir."/micro_".$f); }else{ $nbfiles++ ; echo "
Supprimer  \n"; if($h%9 == 0) echo ""; $h++; } } } closedir($dir); }else { $h=0; } if(isset($_FILES['userfile']['tmp_name'])){ if (($h==0)||($h==1)) { $nom_photo = "avatar_".un_nom(10) . ".jpg" ; }else{ $nom_photo = un_nom(10) . ".jpg" ; } if($_GET[maxfiles]!=''){ $nom_photo = "photo.jpg" ; } if(!is_dir($thedir)){mkdir($thedir, 0777);chmod($thedir, 0777);} if (!(move_uploaded_file($_FILES['userfile']['tmp_name'], $thedir . $nom_photo))) { echo "" ; }else{ chmod ($thedir . $nom_photo, 0777); $size = GetImageSize($thedir.$nom_photo); $src_w = $size[0]; $src_h = $size[1]; if (($src_w > 600) || ($src_h > 600)) { redimage($thedir . $nom_photo,$thedir . $nom_photo,600,600,'.jpg'); chmod ($thedir . $nom_photo, 0777); } redimage($thedir . $nom_photo,$thedir . "mini_".$nom_photo,300,300,'.jpg'); redimage($thedir . $nom_photo,$thedir . "micro_".$nom_photo,80,60,'.jpg'); $nbfiles++ ; echo "
Supprimer\n"; } } if($nbfiles >= 1 ){ echo ""; }else{echo "";} echo "\n"; echo " " ; ?>