Jump to content

Accepting Uploaded Files


prcollin

Recommended Posts

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
Share on other sites

$_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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.