type from PHP
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:
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.
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.
链接地址: http://www.djcxy.com/p/45500.html上一篇: 应用程序/ msword而不是application / vnd.ms
下一篇: 从PHP中输入