0

我将此波纹管方法称为 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;
      }
   } 

问题

  1. 什么是getID3
  2. 为什么这个类改变文件我的类型
4

2 回答 2

3

文件.docxzip文件- 尝试将其重命名为并打开它。您将看到它是 XML 和其他嵌入式文档的集合。.zip

也就是说,getId3设计用于多媒体文件类型 - 视频和音频文件 - 正如它在项目页面上所说

它是 Mime 类型而不是 Mine 类型。它类似于文件扩展名,但功能更强大。它让不同的应用程序(可能在不同的平台上)知道应该如何处理特定的文件。尝试阅读此页面以获取更多信息。

于 2013-03-27T08:49:26.847 回答
1

这个 getID3 库中似乎有一个错误;至少在当前版本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/zipapplication/vnd.openxmlformats-officedocument.wordprocessingml.document.docx

于 2013-03-27T09:25:40.057 回答