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; } Link to comment https://forums.phpfreaks.com/topic/183403-upload-photo-limits/ 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;} Link to comment https://forums.phpfreaks.com/topic/183403-upload-photo-limits/#findComment-968076 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 Link to comment https://forums.phpfreaks.com/topic/183403-upload-photo-limits/#findComment-968136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.