Amaresh Rajaratnam

Official Website of Amaresh Rajaratnam | Entrepreneur

Forums

Post Reply
Forum Home > Beginners Learning - PHP > How to Limit Upload Types?

Kynam Nixsan
Limited Member
Posts: 2

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..? :(

July 8, 2012 at 8:32 AM Flag Quote & Reply

Amaresh
Site Owner
Posts: 11

You should include a code to define that you are allowing to upload a file.

 

$file_type = $_FILES['uploaded_file']['type'];

 

The you should include a code to limit the file types. such as for an example like the following

 

if(isset($_FILES['uploaded_file'])) {
$errors = array();
$maxsize = 2097152;
$acceptable = array(
'application/pdf',
'image/jpeg',
'image/jpg',
'image/gif',
'image/png'

--


October 2, 2012 at 11:28 AM Flag Quote & Reply

You must login to post.