0

我在我拥有的大多数服务器上都试过这个,PHP 似乎返回application/ogg了 ogv 视频文件。这很奇怪,因为 Apache mime 配置文件清楚地列出了video/ogg(也是不可取的,但至少它是有意义的,因为信息应该来自那里)。最初我在响应式文件管理器中遇到了这个问题,但能够独立重现它。

编码:

$fileinfo = finfo_open(FILEINFO_MIME);
$mime_type = finfo_file($fileinfo, $file);
finfo_close($fileinfo);

var_dump($mime_type);

输出:

string(31) "application/ogg; charset=binary"

这些信息来自哪里,我该如何更改?

放置 .htaccess 指令似乎根本没有帮助。我正在运行 cPanel/WHM 可能也很重要,但找不到任何其他相关配置。此外,cPanel 也video/ogg为 ogv 提供,就像 Apache 一样。

4

1 回答 1

0

正在使用finfo_fileLinuxfile命令:https ://linux.die.net/man/1/file

输出finfo_file

application/ogg; charset=binary

的输出file -i sample.ogv

application/ogg; charset=binary

一种解决方案是使用apache_lookup_uri听起来可能对您有用的方法,因为您在 Apache 上运行:http: //php.net/apache_lookup_uri

var_dump( apache_lookup_uri('sample.ogv') );

object(stdClass)#1 (16) {
  ["status"]=>
  int(200)
  ["the_request"]=>
  string(27) "GET /tmp/test.php HTTP/1.1"
  ["method"]=>
  string(3) "GET"
  ["mtime"]=>
  int(0)
  ["clength"]=>
  int(0)
  ["chunked"]=>
  int(0)
  ["content_type"]=>
  string(9) "video/ogg"
  ["no_cache"]=>
  int(0)
  ["no_local_copy"]=>
  int(1)
  ["unparsed_uri"]=>
  string(16) "/mime/sample.ogv"
  ["uri"]=>
  string(16) "/mime/sample.ogv"
  ["filename"]=>
  string(48) "/tmp/sample.ogv"
  ["allowed"]=>
  int(0)
  ["sent_bodyct"]=>
  int(0)
  ["bytes_sent"]=>
  int(0)
  ["request_time"]=>
  int(1504107700)
}
于 2017-08-30T15:45:29.973 回答