I currently have a page on my server which contains links that allow me to download files from a specific folder on my server.
The links are made like :
<a href='file.php?file=$fileName'>FILE</a>
When I click on the link the file is read by file.php and then downloaded. file.php is similar to this :
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename='.$file.'.zip');
header('Content-Length: ' . filesize($tmp));
ob_flush(); flush();
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
ob_flush(); flush();
}
This is all working fine, but there is a slight delay as file.php compresses the file before it's downloaded.
I'm hoping to use Jquery to create an overlay to display 'please wait', run file.php and then close the overlay when the download starts.
$(".file").click(function(){
var file = $(this).data("id");
jQuery.colorbox({html:"<p>PLEASE WAIT</p>"});
$.ajax({
load: 'file.php?file=' + file
});
});
This shows the overlay but the file never downloads. Is there anyway I can call file.php and it run as if it was clicked normally so the file is downloaded?
Thanks