[SOLVED] Submits in FF, and not IE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

[SOLVED] Submits in FF, and not IE

Post 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?
Last edited by $var on Thu Dec 15, 2005 3:21 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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']
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that's correct.. That's why it's really bad to assume the button will exist in the submission.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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?
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post 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.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
Post Reply