cksraj Posted November 20, 2009 Share Posted November 20, 2009 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 More sharing options...
emopoops Posted November 20, 2009 Share Posted November 20, 2009 yeah u check if the files are of those an and if they arent dont allow the file Link to comment https://forums.phpfreaks.com/topic/182253-verifying-file-type-_files/#findComment-961722 Share on other sites More sharing options...
cksraj Posted November 20, 2009 Author Share Posted November 20, 2009 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 https://forums.phpfreaks.com/topic/182253-verifying-file-type-_files/#findComment-961733 Share on other sites More sharing options...
Trizen Posted November 20, 2009 Share Posted November 20, 2009 make a validation checking for the file ext to look for .doc .pdf .xls or .ppt. Link to comment https://forums.phpfreaks.com/topic/182253-verifying-file-type-_files/#findComment-961738 Share on other sites More sharing options...
emopoops Posted November 20, 2009 Share Posted November 20, 2009 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 https://forums.phpfreaks.com/topic/182253-verifying-file-type-_files/#findComment-961740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.