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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.