Page 1 of 1

Page Stuck After Force Download

Posted: Tue Nov 23, 2004 6:14 am
by thomas777neo
Hi All

I have generated an excel spreadsheet, which I force download using this code:

Code: Select all

<?php
header('Content-Description: File Transfer'); 
header('Content-Type: application/force-download'); 
header('Content-Length: ' . filesize($filename)); 
header('Content-Disposition: attachment; filename=' . basename($filename)); 
@readfile($filename); 
?>
Yet, after clicking on the link that sends the $filename to the stipulated code.

I cannot go to any other page on the menu I have that is in the leftFrame. The current active page where I downloaded the file from is stuck.

Any suggestions?

Posted: Tue Nov 23, 2004 6:22 am
by phpScott
what i ended up doing which works for me is

Code: Select all

&lt;a href="download.php?fileToDownload=nameOfFileToDownload.csv&gt;
then in download.php

Code: Select all

<?php
if(isset($_GET['fileToDownload']))
{
header('Content-type: application/csv');
$fileToDownload=$_GET['fileToDownload'];
// It will be called downloaded.pdf
header("Content-Disposition: attachment; filename="$fileToDownload"");
readfile("./outfile/$fileToDownload");
}
else
  echo "unable to find ".$_GET['fileToDownload'];
?>
which opens up the open/save dialague box and the links on my original page still work.

Posted: Tue Nov 23, 2004 6:33 am
by John Cartwright
looks like there might be an error in the readfile function. Remove the @ as it supresses any errors.

Still problematic

Posted: Tue Nov 23, 2004 6:40 am
by thomas777neo
Your code definitely brings up the save box, I can also save the file.
But if I click on my menu item which is in a separate frame. The main (page loading) frame remains stuck.

removed @

Posted: Tue Nov 23, 2004 6:51 am
by thomas777neo
It still works, yet the same problem persists