I am working on a site were I need to upload images and resize them to thumbnails. I followed the tutorial and it works fine for firefox, but not ie.
Here are some of the errors I have been getting:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 131
Warning: imagesx(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 141
Warning: imagesy(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 141
Warning: imagesx(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 155
Warning: imagesy(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 156
Warning: imagecreatetruecolor(): Invalid image dimensions in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 158
Warning: imagesx(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 159
Warning: imagesy(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 159
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/.ginko/jaccrock/jcstrategies.com/jeff/admin/featured_listings.php on line 159
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AND SOME CODE:
Code: Select all
while($_FILES['image_' . $a]['name'] != "")
{
$filename = $_FILES['image_' . $a]['name'];
$temporary_name = $_FILES['image_' . $a]['tmp_name'];
$mimetype = $_FILES['image_' . $a]['type'];
$filesize = $_FILES['image_' . $a]['size'];
switch($mimetype)
{
case "image/jpg":
case "image/jpeg":
$i = imagecreatefromjpeg($temporary_name);
break;
case "image/gif":
$i = imagecreatefromgif($temporary_name);
break;
case "image/png":
$i = imagecreatefrompng($temporary_name);
break;
}
unlink($temporary_name); // deletes the uploaded file
if(imagejpeg($i,"../uploads/" . $_POST['mlsid'] . "_" . $a . ".jpg",80)) // saves a copy of original image uploaded
$images_uploaded = "trUE";
else
$images_uploaded = "FALSE";
$sql .= ", '../uploads/" . $_POST['mlsid'] . "_" . $a . ".jpg'";
$dest_x = 150;
$dest_y = 150;
if (imagesx($i) > $dest_x or imagesy($i) > $dest_y) {
// Is the width of the original bigger than the height?
if (imagesx($i) >= imagesy($i))
{
$thumb_x = $dest_x;
$thumb_y = imagesy($i)*($dest_x/imagesx($i));
} else {
$thumb_x = imagesx($i)*($dest_y/imagesy($i));
$thumb_y = $dest_y;
}
}
else
{
// Using the original dimensions
$thumb_x = imagesx($i);
$thumb_y = imagesy($i);
}
$thumb = imagecreatetruecolor($thumb_x,$thumb_y);
imagecopyresampled($thumb, $i ,0, 0, 0, 0, $thumb_x, $thumb_y, imagesx($i), imagesy($i));
if(imagejpeg($thumb, "../thumbnails/" . $_POST['mlsid'] . "_" . $a . ".jpg", 80))
$images_uploaded = "trUE";
else
$images_uploaded = "FALSE";
$sql .= ", '../thumbnails/" . $_POST['mlsid'] . "_" . $a . ".jpg'";
$a++;
}Any ideas would be greatly appreciated!