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 Link to comment https://forums.phpfreaks.com/topic/59290-accepting-uploaded-files/ 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/ Link to comment https://forums.phpfreaks.com/topic/59290-accepting-uploaded-files/#findComment-294513 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 Link to comment https://forums.phpfreaks.com/topic/59290-accepting-uploaded-files/#findComment-294682 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. Link to comment https://forums.phpfreaks.com/topic/59290-accepting-uploaded-files/#findComment-294692 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 Link to comment https://forums.phpfreaks.com/topic/59290-accepting-uploaded-files/#findComment-295148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.