2

Hi how do i allow only word documents? And i mean both mime-type and extension? Right now i have these codes checking extensions for .txt files, how do i change it to accept only word docs.

if ($uploaded_type !=="text/plain") 

and

if($ext !== 'txt')
1
  • 2
    Just a note - you can't trust the supplied mime type or extension. Be sure to do some sort of validation on it if the type really matters. Commented Nov 22, 2010 at 17:52

3 Answers 3

2

MS Word documents are application/msword or application/vnd.openxmlformats-officedocument.wordprocessingml.document mime types and doc or docx extensions.

Sign up to request clarification or add additional context in comments.

Comments

1

application/msword for .doc and application/vnd.openxmlformats-officedocument.wordprocessingml.document for .docx.

See http://filext.com/faq/office_mime_types.php

Comments

-1

I belive https://www.php.net/manual/en/function.finfo-file.php is what you are looking for

1 Comment

Squadroo wanted the actual MIME type to check if the MIME type he gets (with that or a similar function) is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.