Raul Leaño Martinet
Raul Leaño Martinet

Reputation: 2113

read microsoft excel, word and powerpoint info using PHP

i want my PHPapp to read a file and tell me if it's a word, excel or powerpoint file. my first approach was to read the extension of the file. But microsoft has different file extension names, and i was also wondering about files uploaded by a mac (with no filename extension)

So, maybe the answer is using mimetypes. Do you know a better approach for this?

Upvotes: 1

Views: 752

Answers (1)

Gordon
Gordon

Reputation: 316939

Yes, trying to determine the MimeType is your best bet short of just try/catching to load the files with PHPWord, PHPExcel and PHPowerpoint directly to see if they throw an exception (Mark Baker correct me please if they dont throw exceptions).

See my answer to

for various ways to detect the MimeType.

You can find a number of possible MimeTypes for Office documents at

Upvotes: 2

Related Questions