【问题标题】:Return file contents with Content-type from Javascript从 Javascript 返回具有 Content-type 的文件内容
【发布时间】:2015-04-26 11:11:14
【问题描述】:

我正在尝试在 Weebly 网站中包含 vCard,但我需要返回 Content-type 标头,因此无法使用简单的附件。我在 PHP 中找到了以下代码来执行此操作,但我不能在 Weebly 上包含 PHP 代码,只能包含 Javascript:

<?php
    header("Content-type: text/x-vcard");
    header("Content-Disposition: attachment; filename=\"contact.vcf\";");
    echo file_get_contents("contact.vcf");
?>

有没有办法在 Javascript 中包含一个按钮?

【问题讨论】:

标签: javascript content-type


【解决方案1】:

您应该能够将它添加到一个简单的锚标记中,并且浏览器会处理它。

<a href="contact.vcf">My Contact</a>

【讨论】:

  • 也许我做错了,但根据this website:“Blackberry 无法直接从 QR 码读取 vCard,但您可以对返回 vCard 的 URL 进行 qr 编码。您需要发回这个 PHP 标头: header("Content-type:text/x-vcard");" href= 就够了吗?
  • 不知道,你能测试一下吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-12
  • 2016-01-23
  • 1970-01-01
  • 2014-10-06
相关资源
最近更新 更多