Slight problem downloading
Posted: Wed Jul 14, 2010 9:30 am
My issue is with the actual downloading of the file... the user gets the dialogue to open, save, or cancel. once they click save... it sits there at 99% for about 10 seconds and then says its finished downloading.
I can’t figure out what this delay is about!
here is the entire story of how this all works:
So I have a form to select some options (theform.php)... The form then submits to a 'creation' page that creates a PDF (creator.php) of the users stored data based on the previously selected options. TCPDF then writes the PDF to a file outside the website (website root: /websites/mysite.com, PDF file path: /websites/tmp).
Once it creates the file it executes the following:
Once back to the original page I start the download with the following:
quick explanation of file name... The file name is auto generated in creator.php with the following: md5(date('mdYhi').TENANT_ID)
in the code above it predicts the file name with the same action. The only reason to do this is to avoid any injection to download files as well as only allow a file to be downloaded within the minute it was created. There are obvious flaws with this, but this isn’t much of an issue or the subject of this post (but suggestions are welcome).
to get back on track... I’m not sure what’s going it... I have tried computers outside of my office as well as latest versions of IE, Chrome, and Firefox.
any suggestions?
I can’t figure out what this delay is about!
here is the entire story of how this all works:
So I have a form to select some options (theform.php)... The form then submits to a 'creation' page that creates a PDF (creator.php) of the users stored data based on the previously selected options. TCPDF then writes the PDF to a file outside the website (website root: /websites/mysite.com, PDF file path: /websites/tmp).
Once it creates the file it executes the following:
Code: Select all
header("location: /theform.php?dl")Code: Select all
if(isset($_GET['dl'])){
$file = TMP_PATH.md5(date('mdYhi').TENANT_ID).".pdf";
if (file_exists($file)) {
header("Content-type: application/pdf");
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($file));
header("Content-disposition: attachment; filename='BoundBook-".date('m-d-Y').".pdf'");
readfile("$file");
header("location: /index.php?main_page=exporter");
} else {
$error = "Could not find file";
}
}in the code above it predicts the file name with the same action. The only reason to do this is to avoid any injection to download files as well as only allow a file to be downloaded within the minute it was created. There are obvious flaws with this, but this isn’t much of an issue or the subject of this post (but suggestions are welcome).
to get back on track... I’m not sure what’s going it... I have tried computers outside of my office as well as latest versions of IE, Chrome, and Firefox.
any suggestions?