PHP Classes

Bug IE file type

Recommend this page to a friend!

      Image Upload  >  All threads  >  Bug IE file type  >  (Un) Subscribe thread alerts  
Subject:Bug IE file type
Summary:A fix to fyle type image/png on IE
Messages:3
Author:Cassiano Aquino
Date:2008-09-06 18:12:26
Update:2008-09-06 20:15:07
 

  1. Bug IE file type   Reply   Report abuse  
Picture of Cassiano Aquino Cassiano Aquino - 2008-09-06 18:12:26
A have made a few tests, so a found a bug on IE.

Some PNGīs image are not identified as image/png but so image/x-png

so a fixed this like this...


private function processImages() {
if (empty($this->fileroot)) {
$this->buildFileName();
}

switch($this->imgOriginal['type']) {
case "image/jpg":
case "image/jpeg":
case 'image/pjpeg':
$img = imagecreatefromjpeg($this->imgOriginal['tmp_name']);
break;
case "image/gif":
$img = imagecreatefromgif($this->imgOriginal['tmp_name']);
break;
case "image/png": // FF

////////////////////////////////////////////////////
case "image/x-png"; // IE <-----THE FIX IS HERE :)
////////////////////////////////////////////////////

$img = imagecreatefrompng($this->imgOriginal['tmp_name']);
break;
default:
$this->status = ImageUploader::INVALID_FILE_TYPE;
return $this->status;
}


So this is a small contribution to this good class....

PS: sorry my not good english, i am brazilian.

  2. Re: Bug IE file type   Reply   Report abuse  
Picture of Matt Belanger Matt Belanger - 2008-09-06 19:50:50 - In reply to message 1 from Cassiano Aquino
Thanks for pointing that out. I will definitely add that change and upload the fix.

Hope you find the class useful.

  3. Re: Bug IE file type   Reply   Report abuse  
Picture of Cassiano Aquino Cassiano Aquino - 2008-09-06 20:15:08 - In reply to message 2 from Matt Belanger
Well i would like to give you a sugestion about the file names you generate...

This line..

// I did not understand why you did like this
$imageName = strtolower(preg_replace('/\.tmp/','',$imageNamePcs[count($imageNamePcs)-1]));



i realy dontīlike this kind a rename method...

So a changed for this.

$imageName = md5(uniqid(time()));

I think itīs safe for images name not be replaced...


I hope this tips are usefull, your class is very good :)

 
For more information send a message to info at phpclasses dot org.