Jump to content

Verifying File Type $_FILES[][]


cksraj

Recommended Posts

Hi All,

 

I am getting file input from the user in my application. I would like to allow only specific types of file listed below;

 

  'PDF' => 'application/pdf',

  'DOC' => 'application/msword',

  'XLS' => 'application/vnd.ms-excel',

  'PPT' => 'application/vnd.ms-powerpoint',

 

From the above list except "PDF", for other types $_FILES["userFile"]["type"] value is 'application/octet-stream'. When I allow 'application/octet-stream' it allows db,exe and etc...Is it possible to allow only the above types of file?

 

Thanks

Crew Kasy

Link to comment
Share on other sites

Hi Emopoops

 

Thanks for your reply. But did you get my question?

 

The value of $_FILES["userFile"]["type"] is always 'application/octet-stream' when I select 'DOC', 'XLS' 'PPT' files.

 

So how to check if the files are of those types?????????

 

Thanks

Crew Kasy

Link to comment
Share on other sites

someone told me on here that files[][] isnt safe being it is just from the browser and not from the actual file.. then they went on to explain what you should use to figure out the file type.......

this topic:http://www.phpfreaks.com/forums/index.php/topic,277471.msg1312686.html#msg1312686

its called finfo() or something i still dont understand how to use to get file types

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.