Hi i'm trying to upload an image using a php script. And whats really weird is i get the following error only in Internet Explorer everywhere else script works fine:
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
Here is the 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);
}
}