vCard .vcf文件下载浏览器支持 - godaddy

tho*_*hom 3 .htaccess vcf-vcard

我在网站上有一个下载vCard(.vcf)链接.它在本地工作但不在线.只需在浏览器中打开文件而无需下载 我宁愿不必拉链.

读一遍,发现我需要把它:

AddType text/x-vcard .vcf
Run Code Online (Sandbox Code Playgroud)

在.htaccess文件中.但它仍然无法正常工作.我错过了什么吗?

该网站由godaddy托管.我在某处找到的一个老线程有一个让它工作的人,但除了.htaccess位之外没有其他信息.

Pek*_*ica 5

作为第一步,请求Godaddy他们是否支持AddType指令,如果是,支持指令.这个解决方案绝对是可取的.

或者,您可以使用发送正确标头的原始PHP脚本来解决它.

contact.php(未经测试):

<?php
  # Send correct headers      
  header("Content-type: text/x-vcard"); 
                    // Alternatively: application/octet-stream
                    // Depending on the desired browser behaviour
                    // Be sure to test thoroughly cross-browser

  header("Content-Disposition: attachment; filename=\"contact.vcf\";");
  # Output file contents 
  echo file_get_contents("contact.vcf");
 ?>
Run Code Online (Sandbox Code Playgroud)

这将使用正确的标头为VCF文件提供服务.