chris_s_22 Posted November 30, 2009 Share Posted November 30, 2009 ive got a upload photo script and im just trying to make more secure currently it limits size and as you can see from my code below it limits only gif and php files how do i edit my code to limit all these or do i have to copy and paste the same code and change the file extention? jpg, jpeg, pjpeg, PJPEG, JPG, JPEG, gif, GIF, png, PNG if (!($uploaded_type=="image/gif")) { echo "You may only upload GIF files.<br>"; $ok=0; } also ive restricted php is there anything else i need to restrict? if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } Quote Link to comment Share on other sites More sharing options...
chris_s_22 Posted November 30, 2009 Author Share Posted November 30, 2009 would this be ok? $types = array("type/jpg", "type/jpeg", "type/pjpeg", "type/PJPEG", "type/JPG", "typ/JPEG", "type/gif", "type/GIF", "type/png", "type/PNG");if(!in_array($uploaded_type,$types)){ echo "Invlaid file type"; $ok = 0;} Quote Link to comment Share on other sites More sharing options...
play_ Posted November 30, 2009 Share Posted November 30, 2009 $allowed = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG); echo ( in_array(exif_imagetype($image), $allowed) ) ? 'good image type': 'invalid image type'; // $image above would be $_FILE['whatever']['tmp_name'] Here are the allowed types: http://us2.php.net/manual/en/function.exif-imagetype.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.