在我的超文本网页上,我曾向一个应当迫使下载的网址(www.un.org/Depts)提出过JQuery ajax请求?
我的html网页(在点击事件手里连接)。
var file = "uploads/test.css";
$.ajax(
{
type : "POST",
url : "utils/Download_File.php",
data : {"file":file}
})
下载“File.php”的文字也一样。
<?php
Download_File::download();
class Download_File
{
public static function download()
{
$file = $_POST[ file ];
header( Content-Type: application/octet-stream );
header( Content-Disposition: attachment );
readfile( http://localhost/myapp/ . $file);
exit;
}
}
?>
But nothing is happening for some reason? I looked at the response headers in firebug and cant see any problems. Im using Xampp. Any help is much appreciated.
感谢!