prcollin Posted July 10, 2007 Share Posted July 10, 2007 I know the script for uploading and managing uploaded files but how do i specify the file types that are accepted so I can avoid .exe scripts from being uploaded that will mess with my site. I only want graphics, videos, and txt files and pdf Quote Link to comment Share on other sites More sharing options...
clanstyles Posted July 10, 2007 Share Posted July 10, 2007 $_FILES['userfile']['type'] is how you get the type then do like if if($_FILES['userfile']['type'] != image/pjpeg) { //Bad file type delete it or something and echo bad. } else { //lets say it was a good type. } 'text/html', 'text/plain', 'text/css', 'image/gif', 'image/x-png', 'image/jpeg', 'image/tiff', 'image/png', 'image/x-ms-bmp', 'audio/x-wav', 'application/x-pn-realaudio', 'video/mpeg', 'video/quicktime', 'video/x-msvideo', 'application/postscript', 'application/rtf', 'application/pdf', 'application/x-pdf', 'application/x-gtar', 'application/x-tar', 'application/zip', 'application/x-zip-compressed', 'application/mac-binhex40', 'application/x-stuffit', 'application/octet-stream', 'text/javascript', 'application/x-javascript', 'application/x-sh', 'application/x-csh', 'application/x-perl', 'application/x-tcl', 'application/vnd.ms-powerpoint', 'application/ms-powerpoint', 'application/vnd.ms-excel', 'application/msword', 'video/avi', 'java/*', 'application/java', 'image/x-icon', 'image/bmp', 'image/pjpeg', 'application/x-bittorrent' Theres a list of types from http://www.redvodkajelly.com/code/php-file-upload-class/ Quote Link to comment Share on other sites More sharing options...
prcollin Posted July 10, 2007 Author Share Posted July 10, 2007 if($_FILES['userfile']['type'] != image/pjpeg) ^^^^^^ is that how i do it and have to typ ethat for each acceptable style like image/jpeg image/bmp Quote Link to comment Share on other sites More sharing options...
per1os Posted July 10, 2007 Share Posted July 10, 2007 Or turn them into an array and run the check against each item in the array. Quote Link to comment Share on other sites More sharing options...
prcollin Posted July 11, 2007 Author Share Posted July 11, 2007 Or turn them into an array and run the check against each item in the array. oh ok that makes sense 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.