ShoeLace1291 Posted June 11, 2007 Share Posted June 11, 2007 I have a file upload form on my site, but I want it so that the user can only select gif, jpg, etc. How do I do this? Link to comment https://forums.phpfreaks.com/topic/55174-restricting-non-image-files-from-file-upload-form/ Share on other sites More sharing options...
papaface Posted June 11, 2007 Share Posted June 11, 2007 if ($_FILES['inputname']['type'] == "image/gif" || $_FILES['inputname']['type'] == "image/jpg") { //do something } else { //if not a gif or jpg } Link to comment https://forums.phpfreaks.com/topic/55174-restricting-non-image-files-from-file-upload-form/#findComment-272717 Share on other sites More sharing options...
AndyB Posted June 11, 2007 Share Posted June 11, 2007 I'd actually check the file to be sure some donkey hasn't renamed wombat.exe as wombat.gif http://ca.php.net/manual/en/function.getimagesize.php will confirm it's really an image and which type. Link to comment https://forums.phpfreaks.com/topic/55174-restricting-non-image-files-from-file-upload-form/#findComment-272731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.