JPG の強制ダウンロードを可能にする downloadscript を作成したいと考えています。これは私のphpスクリプトです:
<?php
    header("Pragma: public"); // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Description: File Transfer");
    header("Content-Type: image/jpg");
    header('Content-Disposition: attachment; filename="'.basename($GET['a']).'"');
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: ".filesize(($GET['a']));
    readfile(($GET['a']);
?>
これは、私の js コードのコード セグメントです。
function downloadFile(a){
    document.location = "download.php?a="+ a;
}
このコード サンプルでは、何も起こりません。結果を HTML タグに追加すると、ファイルの内容が表示されます。
このファイルをダウンロードするようにブラウザに教える方法はありますか?
編集:スクリプトの更新