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
|
$nom_photo=$_FILES['photo_a_charger']['name'];
$pattern = '/(.jpg)$/i ';
if($nom_photo!=""){
$matches=preg_match($pattern, $nom_photo);
if($matches==1){
$f_tempo= $_FILES["photo_a_charger"]["tmp_name"];
move_uploaded_file($f_tempo,$adresse_photo);
list($width, $height) = getimagesize($adresse_photo);
echo 'photo 1 '.$width.' '.$height.'<br>';
if($width!=1024 || $height!=768) {
echo $msg="La première photo n'a pas la taille demandée (1024x768) mais ".$width.'x'. $height."<br>Toutes les photos sont rejetées<br>";
if(file_exists($adresse_photo)) unlink($adresse_photo);
}
else{
$newwidth = 160;
$newheight = 120;
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($adresse_photo);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb,$adresse_photo_r);
enregistrer_ns($nom_s,$comment_nom_s,$ind_s);
if($nom_c!="") enregistrer_nc($nom_c,$comment_nom_c,$ind_c,$nom_s);
enregistrer_bd($ligne_bd);
echo 'traitement photo 1 OK<br>';
}
}
} |
Partager