1
votes

When uploading a Power Point 2000 document (.ppt) created in Microsoft Power Point it is a returning a mime type of application/vnd.ms-office. I would expect application/vnd.ms-powerpoint to come back from:

    <?php
    $finfo = new finfo(FILEINFO_MIME);
    $mime_type = $finfo->file($filepath);

    // strip off the mime encoding information
    $mime_type = substr($mime_type, 0, strpos($mime_type, ';'));

Any ideas why this maybe the case?

I am running the following:

  • Ubuntu
  • PHP 5.2
  • Apache 2
2
finfo relies on the underlying system's file functionality so you'll probably have to investigate there. Maybe update the mime_magic file.... - Pekka
I can't see any mime types in there of application/vnd.ms-office however so I am still unsure where it is coming from. I have checked the mime_magic file in Apache and the main system one. Any other ideas? - Treffynnon

2 Answers

1
votes

finfo ins't 100% reliable, especially when it comes to Microsoft Office documents. I don't think there is an easy fix to your solution. You might try, if it returns application/vnd.ms-office, then additionally check if the extension of the file is .ppt, and if it is, set the mime type to application/vnd.ms-powerpoint. Of course an extension is meaningless, but those using Microsoft, there is a good chance a file with extension .ppt is a powerpoint and not anything else.

0
votes

Make sure the Apache MIME types file has the correct MIME type for that file extention. You'll want to look at /conf/mime.types and add these lines if they don't exist.

application/vnd.powerpoint ppt
application/vnd.powerpoint pptx

You will need to restart Apache after making these changes.