我将该方法称为GetID3MIMEtype('test.docx'),该方法将文件类型更改为"application/ zip“,但我不会上传任何zip文件--这个不正确的文件类型。
function GetID3MIMEtype($filename) {
$filename = realpath($filename);
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);
getid3_lib::CopyTagsToComments($ThisFileInfo);
log_error(print_r($ThisFileInfo['mime_type'], true));
if (empty($ThisFileInfo['error'])) {
if ($ThisFileInfo['fileformat']) {
$temp = explode("/", $ThisFileInfo['mime_type']);
$mime = $temp[0]."/".$ThisFileInfo['fileformat'];
}
else
$mime = $ThisFileInfo['mime_type'];
return $mime;
}
else {
log_error("ID 3 Error - ".$filename." - ".print_r($ThisFileInfo['error'], true));
return false;
}
} 问题
发布于 2013-03-27 08:49:26
发布于 2013-03-27 09:25:40
这个getID3库中似乎有一个bug,至少在当前版本的getid3-1.9.5-20130220中是这样的。
如果您打开文件module.archive.zip.php并更改该块
if (!empty($ThisFileInfo['zip']['files']['ppt'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
} elseif (!empty($ThisFileInfo['zip']['files']['xl'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
} elseif (!empty($ThisFileInfo['zip']['files']['word'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
}至
if (!empty($info['zip']['files']['ppt'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
} elseif (!empty($info['zip']['files']['xl'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
} elseif (!empty($info['zip']['files']['word'])) {
$info['mime_type'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
}(即将$ThisFileInfo改为$info)
mime类型从application/zip更改为单词.docx的application/vnd.openxmlformats-officedocument.wordprocessingml.document
https://stackoverflow.com/questions/15654652
复制相似问题