简体   繁体   English

仅当数据来自服务器时 Firefox 的 HTML5 下载问题

[英]HTML5 Download issue with Firefox Only When data is from Server

I want to download a JSON file from a server, In google Chrome it is Working fine, But in Firefox its not getting downloaded but opening in a new page.我想从服务器下载一个JSON文件,在谷歌浏览器中它工作正常,但在 Firefox 中它没有被下载而是在新页面中打开。

NB : Firefox download is working fine with Local files注意:Firefox 下载适用于本地文件

How to Solve this issue如何解决这个问题

Demo https://jsfiddle.net/dineshkanivu/24tq2da5/1/演示https://jsfiddle.net/dineshkanivu/24tq2da5/1/

Here is My Code这是我的代码

<a href="http://christtravels.com/js/dk.json" download="some.json">
  Clicked
</a>

I hope this can help you:我希望这可以帮助你:

HTML: HTML:

<a href="test.php">Clicked</a>

in test.php:在 test.php 中:

$download_name = 'http://christtravels.com/js/dk.json';

header('Content-Description: File Transfer');
header('Content-Type: application/json');
header('Content-Disposition: attachment;filename = ' . $download_name);
ob_clean();
flush();

我认为你的download属性应该包含下载的文件名或者只是空的所以试试download="some.json"看看是否有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows 7中的HTML5 Canvas drawImage问题,但仅限于Firefox - HTML5 Canvas drawImage issue in Windows 7 but only in Firefox HTML5下载属性在Firefox 38.0.5中不起作用 - Html5 Download attribute not working in Firefox 38.0.5 从服务器将文件下载到客户端-jquerymobile / html5 / c# - Download file to the client from server - jquerymobile/html5/c# html5 href下载属性问题 - html5 href download attribute issue 将 JPEG 从 html5 画布保存到服务器时出现问题 - Having an issue whilst saving JPEG, from html5 canvas, to server HTML 视频仅出现在 Firefox 中,从本地服务器提供时不会出现在任何其他浏览器中 - HTML video appearing only in Firefox, not in any other browser when served from a local server 使用固定的侧边栏时的HTML5砌体边距/装订线问题(EDGE和Firefox) - HTML5 Masonry Margin / Gutter Issue when using fixed Sidebar (EDGE & Firefox) Fullcalendar无法在drop中访问html5数据属性,仅在Firefox上 - Fullcalendar can't access html5 data attribute in drop, only on Firefox 阻止HTML5投递重定向Firefox - Stop HTML5 drop from redirecting Firefox 在HTML5中,我可以直接从服务器将数据存储到“本地存储”吗? - In HTML5, can I store data to the 'localstorage' directly from server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM