Class method works in firefox but not in IE, why?

Hello everybody,

I’m working on a class which uploads images and one of the method that evaluates the file type works in FireFox but not in IE it throws the error message I have in the script.

Running: Firefox version 19 and IE 8.
I cleared both browser cache and history and still no go…

any ideas as to whats happening?

public function imageType()
{	for($x=0; $x < count($_FILES['data']['name']); $x++)
	{	if(!empty($_FILES['data']['name'][$x]))
		{	if(!in_array($_FILES['data']['type'][$x], $this->allowedType))
			{	$this->errCheck[] = array('Image format not allowed: '. $_FILES['data']['name'][$x]);  }

What is the error as it sounds like a JavaScript issue since PHP executes before the browser renders the page, I have never seen a use case where PHP code fails in a specific browser.

How can it be a JavaScript issue? The script that the OP posted is supposed to be processing uploaded images from a form when they get to the server - as they have PHP on the server there is unlikely to be any JavaScript on the server interfering.

See which explains how Internet Explorer doesn’t always set the MIME type correctly when uploading files - presumably while that particular example doesn’t exactly match this situation, it is an explanation on why server side code that will work with all other browsers doesn’t always work for IE and the cause here is probably similar with IE not setting the correct MIME type for some types of image. To fix it I’d see just what MIME types IE does send for the various valid image types and add them into the array.

First thing to do when tackling an issue is put var_dump($variableYouWantToCheck); in your CODE!

You need to see what you are getting for $_FILES from both browsers and see how that impacts your code, if it isn’t what you expected to receive. Placing the following above your for loop should help


Hello Everybody,

I greatly appreciate everybodys help with this problem.

After posting the message on Sitepoint I did a quick search and came to the same conclusion as Felgalls reply. I’m not an expert on the matter but in my case IE wasn’t correctly setting the MIME type.

Correction made from:

public $allowedType = array(
‘image/png’, );

To fix the problem, see highlighted values below:

public $allowedType = array(


again thanks for everybodys help.