On my HTML page I have made a JQuery ajax request to a php script that should force a download, but nothing is happening?
On my html page (in click event handler for a link)...
var file = "uploads/test.css";
$.ajax(
{
type : "POST",
url : "utils/Download_File.php",
data : {"file":file}
})
And the Download_File.php script looks like this
<?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.
Thanks!