Jump to content

[SOLVED] Here's a weird one ! Why does this happen ?


iPixel

Recommended Posts

Ok so i got this upload script and everything works 100% fine in IE.

At one point in the script i check for file type, i only want jpg files.(code below)

The problem is firefox... whenever i use FF to upload a picture, that code snipped craps out and gives me the error msg.

 

$userfile_name = $_FILES['image']['name'];
$userfile_tmp = $_FILES['image']['tmp_name'];
$userfile_size = $_FILES['image']['size'];
$userfile_type = $_FILES['image']['type'];


if($userfile_type == "image/pjpeg")
	{
		echo "";
	}	
else
	{
	?>
		<center><br /><br /><br />
		<font color="#FF0000">The picture file you are trying to upload is not in jpg format. Please resave the image with the jpg format and try again. Thank You!.</font><BR />
		</center>
		<meta http-equiv=refresh content='5;url=javascript:history.go(-1)'>
	<?
		exit;
	}

 

Any and all ideas suggestions are more then welcome and appreciated !

Thanks

Link to comment
Share on other sites

the else statement is the error msg ...

 

I suppose another way to do this would be to check the remaining characters after the ( . )

and check if they are  jpg, jpeg, JPG, JPEG, right ? but how would i avoid from mis-reading files named

fun.stuff.jpg ?

Link to comment
Share on other sites

image/jpeg  ||  image/jpeg

 

or do you mean image/jpeg  ||  image/jpg ?

 

ill give this a shot .. for now my temporary fix is

 

	$file_ext = substr($userfile_name, -4);

	if(($file_ext == ".jpg") || ($file_ext == ".JPG") || ($file_ext == "jpeg") || ($file_ext == "JPEG"))
		{
			echo "";
		}
	else
		{
			?>
				<center><br /><br /><br />
				<font color="#FF0000">-- The picture file you are trying to upload is not in jpg format. Please resave the image with the jpg format and try again. Thank You!. --</font><BR />
				</center>
				<meta http-equiv=refresh content='5;url=javascript:history.go(-1)'>
			<?
			exit;			
		} 

 

But i still want to figure out why that other snippet wont work ..

 

Thanks Wuhtzu

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.