How to Limit Upload Types?

Hello, I am currently working on a uploading site, but I dont want things like PHP, HTML, CSS, JS, Etc files uploaded. Is there a way I can limit the types of files uploaded to only having a few certain extensions…?

Thanks!

Yep, every file passes information about itself when its uploaded, all contained within $_FILE[]. You’ll have to look up the mime types for each file type you want to not allow. When you have that, put them all into an array, then use a foreach loop to compare the file type against the disallowed mime types.

I dont have much experience with uploading files, can you help with a code?

Thanks!

There are lots of tutorials out there, but here’s an easy one to follow - http://www.w3schools.com/php/php_file_upload.asp

Sponsor our Newsletter | Privacy Policy | Terms of Service