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

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 ?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.