使用.hattaccess添加其他MIME类型;PHP


Add additional MIME types using .hataccess & PHP

当我从Web服务器php下载文件时,获取MIME类型,这样浏览器就知道用什么打开文件。在我的网站上有一个混合的文件类型。

我想在PHP识别列表中添加一个MIME类型:

这就是我的服务器如何使用PHP将文件下载到计算机:

if (file_exists($file)) {
header( 'Cache-Control: public' );
      header( 'Content-Description: File Transfer' );
      header( "Content-Disposition: attachment; filename={$file}" );
      header( 'Content-Type: ' . mime_content_type($file) );
      header( 'Content-Transfer-Encoding: binary' );
      readfile( $file );
      exit;
}

现在一些网站建议您可以使用.hattacces文件添加MIME类型http://www.htaccess-guide.com/adding-mime-types/

这就是我放在htacces文件夹中的内容,这样它就可以识别viso文件格式:

AddType application/x-viso .vsdx

当我从服务器下载一个viso文件时,它不会使用Firefox将其识别为viso文件。我确实安装了viso。有人能帮忙吗?

尝试AddType text/x-visio .vsdx而不是