NYCPHP Meetup

NYPHP.org

[nycphp-talk] Using $_FILES["whatever"]["type"] correctly

Terenzio webmaster at localnotion.com
Wed Jan 14 07:25:01 EST 2004


On Jan 14, 2004, at 12:02 AM, Webapprentice . wrote:

> Hi,
>
> I'm trying to compare the type of file I uploaded with certain MIME 
> types as part of a series of checks.
>
> In one case, $imageType was equal to "image/jpeg" but it still fell 
> into my error area.

By one case, do you mean one particular file always does this , or it 
happened once and not again?



> Why?  I thought at first it was "short-circuiting" on the if 
> statement, but that would apply to && conditions, right?
>
>
> Thanks.
>
>
> Code snippet
> ------------
>
>
> 		if ($_FILES["frontimage"]["name"] != "")
> 		{
> 			$imageType = $_FILES["frontimage"]["type"];
> 		
> 			// Check MIME Type
> 			if ((strtolower($imageType) != "image/png") || 
> (strtolower($imageType) != "image/jpeg") || (strtolower($imageType) != 
> "image/gif"))
> 			{
> 		       	$errorMessage["frontimage"] = "Please upload images with the 
> extension .jpg or .jpeg or .gif or .png only.";
> 				$errors = 1;
> 				echo($imageType);
> 				exit();
> 	   		}
>                  }
>
> -- 
> ___________________________________________________________
> Sign-up for Ads Free at Mail.com
> http://promo.mail.com/adsfreejump.htm
>
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk




More information about the talk mailing list