Jump to content

[SOLVED] GD and IE problems


surfsup

Recommended Posts

I have the following code.

 

$filename = $_FILES['imagefile']['name'];
$temporary_name = $_FILES['imagefile']['tmp_name'];
$mimetype = $_FILES['imagefile']['type'];
$filesize = $_FILES['imagefile']['size'];
$agencyIDimg = $_SESSION['agencyID'];

switch($mimetype) {
    case "image/jpg":
    case "image/jpeg":
case "image/pjpeg":
        $i = imagecreatefromjpeg($temporary_name);
        break;
    case "image/gif":
        $i = imagecreatefromgif($temporary_name);
        break;
    case "image/png":
        $i = imagecreatefrompng($temporary_name);
        break;
}


unlink($temporary_name);


imagejpeg($i,"images/uploadedfile.jpg",80);


$dest_x = 200;
$dest_y = 200;


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 {
    
    $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));


imagejpeg($thumb, "agencyimages/$filename", 80);

 

 

All works fine in FF but IE keeps giving me the following errors. I searched through the forum but can't seem to find an answer.

 

Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 94

Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 101

Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 101

Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 112

Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 113

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\wamp\www\wottodo\imageuploadAgency2.php on line 117

Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 120

Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 120

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 120

Warning: imagejpeg(): supplied argument is not a valid Image resource in C:\wamp\www\wottodo\imageuploadAgency2.php on line 123

 

Any help would be great

Link to comment
Share on other sites

change

switch($mimetype) {
    case "image/jpg":
    case "image/jpeg":
case "image/pjpeg":
        $i = imagecreatefromjpeg($temporary_name);
        break;
    case "image/gif":
        $i = imagecreatefromgif($temporary_name);
        break;
    case "image/png":
        $i = imagecreatefrompng($temporary_name);
        break;
}

 

to

switch($mimetype) {
    case "image/jpg":
       $i = imagecreatefromjpeg($temporary_name);
    case "image/jpeg":
       $i = imagecreatefromjpeg($temporary_name);
case "image/pjpeg":
        $i = imagecreatefromjpeg($temporary_name);
        break;
    case "image/gif":
        $i = imagecreatefromgif($temporary_name);
        break;
    case "image/png":
        $i = imagecreatefrompng($temporary_name);
        break;
}

Link to comment
Share on other sites

really need more info, try this and post the results

//added
print_r($_FILES);
die("END");

switch($mimetype) {
    case "image/jpg":
       $i = imagecreatefromjpeg($temporary_name);
    case "image/jpeg":
       $i = imagecreatefromjpeg($temporary_name);
case "image/pjpeg":
        $i = imagecreatefromjpeg($temporary_name);
        break;
    case "image/gif":
        $i = imagecreatefromgif($temporary_name);
        break;
    case "image/png":
        $i = imagecreatefrompng($temporary_name);
        break;
default:
    die("FAILED: Bad mimetype");
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.