astralaaron Posted February 1, 2008 Share Posted February 1, 2008 Hey I have options on a website for the admin to post pictures. since it was just the admin posting the pictures i did not think to worry about what kind of file was being uploaded.now they want the members to also be able to post pictures.. and i thought ok no problem... but then i realized what if some person uploaded a huge file, or some other file type...can someone tell me how to check if the file is right? jpg, gif or whatever common image types please help, thanks! Link to comment Share on other sites More sharing options...
killboy Posted February 1, 2008 Share Posted February 1, 2008 http://www.w3schools.com/php/php_file_upload.asp Link to comment Share on other sites More sharing options...
justsomeguy Posted February 4, 2008 Share Posted February 4, 2008 The best way is to just have a list of allowed extensions and to check the extension. You can get the extension of a filename like this:$ext = array_pop(explode(".", $fname));You can compare that with an array of allowed extensions to see if it's valid or not. $allowed = array('jpg', 'gif', 'png');if (in_array($ext, $allowed)) echo "ok";else echo "not ok"; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.