php validation for image

function isValidImageFile($image_type){
		$imageType=explode("/",$image_type);
		switch(trim(strtolower($imageType[1]))){
			case 'jpeg':$returnValue=1;break;
			case 'pjpeg':$returnValue=1; break;
			case 'gif':$returnValue= 1; break;
			case 'png':$returnValue= 1; break;
			/* if you want more extension than just keep on adding like ###
			example::

			case 'extension':$returnValue=1;break;


			######
			*/
			default:$returnValue=0;
		}
		return $returnValue;
	} // author : http://rajanmaharjan.com.np

This Post Has One Comment

  1. well, its a terrific code!!!

    I have implemented it on my most of the projects , n is really flexible.
    Nice job dude!!

Leave a Reply

Close Menu