Bonjour, j'essaie de télécharger une image en utilisant un script PHP. Et ce qui est vraiment bizarre est que je reçois l'erreur suivante dans Internet Explorer fonctionne partout ailleurs scénario bien:Problèmes de téléchargement de fichiers en PHP
Warning: move_uploaded_file(pictures/) [function.move-uploaded-file]: failed to open stream: Is a directory in /home/tntauto1/public_html/admin_add1.php on line 59
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpcJnHZE' to 'pictures/' in /home/tntauto1/public_html/admin_add1.php on line 59
Warning: copy() [function.copy]: The first argument to copy() function cannot be a directory in /home/tntauto1/public_html/admin_add1.php on line 60
Voici le script:
if(is_uploaded_file($_FILES['image']['tmp_name'])){
if($_FILES['image']['type'] == 'image/jpeg'){
$original = 'original_'.$v_id.'.jpg';
$large = 'large_'.$v_id.'.jpg';
$small = 'small_'.$v_id.'.jpg';
}elseif($_FILES['image']['type'] == 'image/gif'){
$original = 'original_'.$v_id.'.gif';
$large = 'large_'.$v_id.'.gif';
$small = 'small_'.$v_id.'.gif';
}else{
$error = 'Error: The image could not be uploaded. It must be in .jpg, .jpeg or .gif format.';
}
if(move_uploaded_file($_FILES['image']['tmp_name'],'pictures/'.$large)){}
copy('pictures/'.$large,'pictures/'.$small);
$imgsize = getimagesize('pictures/'.$large); //>>>>>>>>>>>>>>>>>>>>>>>>>>>>---- Resize to 480 X 360
$width = $imgsize[0];
$height = $imgsize[1];
if(($width > 480) || ($height > 360)){//resize the image
$ratio = $width/$height;
if(100/$ratio >= 80){//calculates if height of uploaded image is too large
$new_width = floor(360 * $ratio);
$new_height = 360;
}elseif(150 * $ratio > 100){// calculate if width of uploaded image is too large
$new_width = 480;
$new_height = floor(480/$ratio);
}
if($_FILES['image']['type'] == 'image/jpeg'){
$img = imagecreatefromjpeg('pictures/'.$large);
$img_copy = imagecreatetruecolor($new_width,$new_height);
imagecopyresampled($img_copy,$img,0,0,0,0,$new_width,$new_height,$width,$height);
imagejpeg($img_copy,'pictures/'.$large,100);
}
if($_FILES['image']['type'] == 'image/gif'){
$img = imagecreatefromjpeg('pictures/'.$large);
$img_copy = imagecreatetruecolor($new_width,$new_height);
imagecopyresampled($img_copy,$img,0,0,0,0,$new_width,$new_height,$width,$height);
imagejpeg($img_copy,'pictures/'.$large,100);
}
}
Bonjour à tous pour votre contribution. Ne pas le vérifier par le type de fichier $ _FILES ['nom'] ['type'] l'a corrigé. (désolé je n'ai pas mentionné $ grande variable est définie plus tôt dans le script que je n'ai pas posté) – Ross