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
https://forums.phpfreaks.com/topic/182253-verifying-file-type-_files/
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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.