Page 1 of 1

[SOLVED] Submits in FF, and not IE

Posted: Thu Dec 15, 2005 9:21 am
by $var
I have a multi-image upload that is working in firefox, but won't in IE... figures.

I was wondering if anyone had an idea about that... i thought that maybe the submit button wasn't set to submit or something, or that the name wasn't working, but I think it looks good. Here's the code:


Code: Select all

<?  
	$link = mysql_connect("localhost", "", "")
	or die("Could not connect: " . mysql_error());
	mysql_select_db (_db) or die("db not connected: " . mysql_error());
	if(isset( $Submit )) 
	{ 
	$ID = $_COOKIE["ID02"];
	$path = "/Imi/Mem_Img/".$ID;
	foreach( $HTTP_POST_FILES as $aFile )
	{
		if ($aFile['type'] == "image/gif" || $aFile['type'] == "image/jpeg")
		{
			copy ($aFile['tmp_name'], $path."/".$aFile['name']) 
				or die ("Could not copy"); 
			echo "";
		}
	}

	exit;
}

				if(isset( $Submit )) 
				{ 
					$ID = $_COOKIE["ID02"];
					$path = "http://www.domain.com/Imi/Mem_Img/".$ID;
					foreach( $HTTP_POST_FILES as $aFile )
					{
						if ($aFile['type'] == "image/gif" || $aFile['type'] == "image/jpeg")
						{
							copy ($aFile['tmp_name'], $path."/".$aFile['name']) 
								or die ("Could not copy"); 
							echo "";
							
							
						}
						
					}
					exit;
				}
				?>

				<form name="form1" method="post" action="" enctype="multipart/form-data">
				<input type="file" name="imagefile1" class="text">
				<input type="file" name="imagefile2" class="text">
				<input type="file" name="imagefile3" class="text">
				<input type="file" name="imagefile4" class="text">
				<input type="file" name="imagefile5" class="text">
				<input type="submit" name="Submit" value="Submit" class="text"></td></tr>
				 </form>
Any ideas?

Posted: Thu Dec 15, 2005 9:27 am
by feyd
your code relies on $Submit existing when it does not get sent by IE. Look for a field that should always be there, or better yet, simply detect the post method: $_SERVER['REQUEST_METHOD']

Posted: Thu Dec 15, 2005 1:08 pm
by shiznatix
I thought a submit button would not be sent unless it was actually clicked on in IE (other than the user hitting the enter key)??? am i wrong?

Posted: Thu Dec 15, 2005 1:15 pm
by feyd
that's correct.. That's why it's really bad to assume the button will exist in the submission.

Posted: Thu Dec 15, 2005 1:19 pm
by shiznatix
ah yes, i just use it for when there are different submit buttons for the same form to do different actions. just checking, had my worried there the way i read it at first.

Posted: Thu Dec 15, 2005 2:19 pm
by $var
I am ACTUALLY clicking submit.... here's what I have deduced.

In firefox, both JPG and GIF are fine...
in IE, gif is a go, JPG doesn't work.

is it because i have

if ($aFile['type'] == "image/gif" || $aFile['type'] == "image/jpeg" || $aFile['type']=="image/pjpeg")

would the jpg/jpeg make the difference here?

and how do you get around the enter button issue, that was a big problem at my last job... i think we lost a bunch of hours to it.

thanks

Posted: Thu Dec 15, 2005 2:41 pm
by shiznatix
enter button issue:

just put a <input type="hidde" name="submitting_it" value="true"> then check if that is set, that means the form was submitted! yay.

on the other thing, why not just do a getimagesize() to check if it is a image? whats wrong with png's and bmp's?

Posted: Thu Dec 15, 2005 3:15 pm
by $var
i tried feyd's method: $_SERVER['REQUEST_METHOD'] the result is GET
i tried to echo getimagesize(); and nothing shows up...

there is somethign that isn't allowing me to upload jpg, has this ever happened to anyone?
i have nothing against other file types, just... one step at a time, jpg is crucial

i even tried
|| $aFile['type'] == "image/jpg"

nothing.

Posted: Thu Dec 15, 2005 3:20 pm
by $var
the final outcome of this was:

Code: Select all

if ($aFile['type'] == "image/gif" || $aFile['type'] == "image/png" || $aFile['type'] == "image/bmp" || $aFile['type'] == "image/jpeg" || $aFile['type'] == "image/jpg" || $aFile['type']=="image/pjpeg")

seems to be working in all browsers now.

Posted: Thu Dec 15, 2005 3:28 pm
by shiznatix
getimagesize

it does not return a string, it returns a array. its the most secure way to find out if the file uploaded is a actual image. i don't know if you can fake the image type thing to make it seam like a image, though it really is not, but i would bet money that it could be done.