我将该方法称为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
.docx文件是一个zip文件-尝试将其重命名为.zip并打开它。您将看到它是XML和其他嵌入式文档的集合。
也就是说,getId3被设计用于多媒体文件类型--视频和音频文件--就像它在项目页上所说的那样。
这是米姆型而不是地雷型。它类似于文件扩展名,但功能更强大。它让不同的应用程序(可能在不同的平台上)知道如何处理特定的文件。尝试阅读此页以获得更多信息。
发布于 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
复制相似问题