1

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?

Raul Leaño Martinet
  • 2,035
  • 6
  • 28
  • 44

1 Answers1

2

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

Community
  • 1
  • 1
Gordon
  • 312,688
  • 75
  • 539
  • 559