NYCPHP Meetup

NYPHP.org

[nycphp-talk] File Download Question

Dan Cech dcech at phpwerx.net
Thu Oct 20 13:59:29 EDT 2005


Eddie,

It sounds to me like you may have an issue with your sessions, as 
presumably the php download script is blocking your other pages from 
accessing the session.

If you put a call to session_write_close 
(http://www.php.net/session_write_close) after anything that needs 
access to the session but before the portion of the script that takes a 
long time, it should fix your problem.

Dan


Eddie Haber wrote:
> I have a file download area on my site. Users click a link, a JS pop-up
> window pops with a meta-refresh tag that refreshes to the file to be
> downloaded. The pop-up window also refreshes (reloads) the opener page.
> 
> Everything works great, except one problem. I am using a PHP script as a
> gatekeeper/passthru for the file to be downloaded. Once the file download
> begins, no other links on the browser (parent or pop-up) will resolve until
> the download is over or is stopped. The second the download stops, any
> clicked on link resolves.
> 
> The odd part is: If the meta-refresh in the pop-up goes directly to the zip
> file, the browser can link away without problem. But if meta-refresh links
> to the php script that dispenses the file, the links won't resolve during
> download. Script is below.
> 
> Much appreciated! Thank you,
> Eddie
> 
> 
> <?
> 
> // a bunch of security checking
> 
> // filename (all are zip files)
> $filename = "somepath/somefile.zip";
> 
> // commented headers below are
> // alternate tries that didn't work
> 
> // output
> header("Pragma: public");
> header("Expires: 0"); // set expiration time
> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> header("Cache-Control: public");
> header('Content-Description: File Transfer');
> header("Content-Type: application/zip");
> // header("Content-Type: application/force-download");
> // header("Content-Type: application/octet-stream");
> // header("Content-Type: application/download");
> header("Content-Disposition: attachment;
> filename=".basename($filename).";");
> header("Content-Transfer-Encoding: binary");
> header("Content-Length: " . filesize($filename));
> 
> @readfile("$filename");
> exit;
> 
> ?>
> 
> 
> _______________________________________________
> New York PHP Talk Mailing List
> AMP Technology
> Supporting Apache, MySQL and PHP
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.nyphp.org




More information about the talk mailing list