Hi All,
I have used XMLHttpRequest to a php script where the script will response with a force download using following headers, example.php
header('Content-Description: File Transfer');
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=\"" . basename($newZipFile) . "\"" );
header("Content-Transfer-Encoding: binary");
header("Pragma: public");
header("Cache-Control: no cache, no-store, must-revalidate");
header("Content-Length: " . filesize($newZipFile));
ob_end_flush();
readfile($newZipFile);
exit();
and then, in my Javascript, i have made a blob of the response and save it
if(XHR.status == 200)
{
var blob = new Blob([XHR.response], {type: 'application/zip'});
var fileName = XHR.getResponseHeader("Content-Disposition").match(/\sfilename="([^"]+)"(\s|$)/)[1];
saveBlob(blob, fileName);
}
When force download a 600~MB zip, the ‘Download’ took so long time to start(20 min). BUT, if i replace above the XMLHTTPRequest approach with the Form Handler
<Form action="example.php", method="POST">
Then, the download begin immediately.
Anyone know why such difference happened between this two approach?
My development Enviroment: PHP 5.3.29 Apache 2.2.31