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

使用.hataccess&;添加其他MIME类型;PHP,php,.htaccess,Php,.htaccess,当我从我的Web服务器下载文件时,php获取MIME类型,以便浏览器知道用什么打开文件。在我的网站上有一个混合的文件类型 我想在列表中添加一个MIME类型: 以下是我的服务器使用PHP将文件下载到计算机的方式: if (file_exists($file)) { header( 'Cache-Control: public' ); header( 'Content-Description: File Transfer' ); header( "Content-Dispos

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

我想在列表中添加一个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;
}
现在一些网站建议您可以使用.hatacces文件添加MIME类型

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

AddType application/x-viso .vsdx

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

试试
AddType text/x-visio.vsdx

虽然这个代码片段可以解决这个问题,但确实有助于提高文章的质量。请记住,您将在将来回答读者的问题,这些人可能不知道您的代码建议的原因。