Squadroo
Squadroo

Reputation: 23

php - mime type/extension

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')

Upvotes: 2

Views: 5626

Answers (3)

Ivan
Ivan

Reputation: 2262

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

Upvotes: -1

poke
poke

Reputation: 388253

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

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

Upvotes: 1

ceejayoz
ceejayoz

Reputation: 180136

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

Upvotes: 2

Related Questions