可能重复:
Downloading Via JQuery AJAX Post not workingPHP AJAX jQuery的 - 文件下载问题
filedownload.php低于snippent。
$file = 'cut.png';
header("Content-Type: image/png");
header('Content-Disposition: attachment; filename="'.$file.'"');
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
readfile($file);
exit();
AJAX调用
jQuery.post('filedownload.php',{
'file' : result // not used for the time being
});
我做一个AJAX调用filedownload.php
文件。它不允许用户下载文件。但是如果我直接运行php,它允许用户下载文件。可能是什么问题 ?
我想使用核心函数而不是使用jQuery插件。如果这是不可能的,一个插件会好起来的。
鉴于我使用ajax,因为页面无法刷新。
校验码了这一点:http://stackoverflow.com/questions/676348/allow - 用户对下载文件使用的Ajax –