NYCPHP Meetup

NYPHP.org

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

Webapprentice . webapprentice at mail.com
Wed Jan 14 00:02:40 EST 2004


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




More information about the talk mailing list