Page 1 of 1

PHP outputting a file for download.

Posted: Mon Sep 15, 2008 10:10 pm
by EoN
Hi guys,

I've recently moved my web application to a new server, and everything is humming now except for two unusual issues that I was hoping someone could help shed some light on.

1. My web application outputs a file for download using the following code:

Code: Select all

header('HTTP/1.1 200 OK');
header('Date: ' . date("D M j G:i:s T Y"));
header('Last-Modified: ' . date("D M j G:i:s T Y"));
header("Content-Type: application/octet-stream");
header("Content-Length: " . (string)(filesize($fileHandle)) );
header("Content-Transfer-Encoding: Binary");
header('Content-Disposition: attachment; filename="'.$fileName.'"' );
readfile($fileHandle); 
On my previous server, the browser's download dialog would display the 'total file size' (ie "Downloading X bytes of TOTAL_SIZE").

On my new server it doesn't display the total filesize, and thus doesn't display the estimated time. Does anyone know what might cause this total filesize to not be picked up? And how can it be corrected?


2. While the file is downloading, any further requests/refreshes on the web site seem to just time out. As soon as the download finishes, I can view the site easily again. I'm guessing this must be some sort of 'one connection per session or per ip' type thing?

If anyone could help, would be much appreciated :)

Regards,
EoN