Greetings all,
Thanks for reading this.
We've recently had an error on one of our webpages where users can upload image files. This upload form has been working fine for some time now and I'm thining this might be related to the mime-type of the image uploaded. I've not seen a image/x-citrix-pjpeg file before.
My question is does the php image function imagecreatefromjpeg() work with the mime-type image/x-citrix-pjpeg?
synopsis of the code:
We do a preg_match to see if the image is in the types we allow ( gif, jpg, jpeg and png ). It passes this since due to the jpeg in pjpeg.
Next we get the image size using getimagesize() to see if it needs to be resized.
If it does I call resizeImage(), a homegrown function in an includes file.
If the image cannot be resized, we return false and do a confess with "the image is too large and cannot be resized" message. This is what we saw in this paticular error.
In resizeImage() we have a switch statement:
$info = getimagesize($file); // $file passed into function
switch ($info[2]) {
case IMAGETYPE_GIF:
$image = imagecreatefromgif($file);
break;
case IMAGETYPE_JPEG:
$image = imagecreatefromjpeg($file);
break;
case IMAGETYPE_PNG:
$image = imagecreatefrompng($file);
break;
default:
return false;
}
I'm thinking that the case line IMAGETYPE_JPEG is not getting run and the code is dropping through to the return false. This is why I believe the mime-type image/x-citrix-pjpeg is causing this.
Thoughts?
Here is the info in the $_FILES array.
$_FILES
array(1) {
["imagefile"]=>
array(5) {
["name"]=>
string(52) "35806_1418596538051_1026759583_31036444_387798_n.jpg"
["type"]=>
string(20) "image/x-citrix-pjpeg"
["tmp_name"]=>
string(14) "/tmp/phpGxBAgc"
["error"]=>
int(0)
["size"]=>
int(123661)
}
}
Thanks for any ideas or tips.