[thelist] Sending File Size headers in PHP

Tony Grimes info at scribenewmedia.com
Sun Oct 19 17:07:48 CDT 2003


Thanks for the suggestion Anthony. I couldn't get your code to work the way
I wanted to, so I dived into the HTTP specs and pulled this out:

header("Content-Length: $file_size");

It seems to work on all the browsers that can download the file in the first
place, but I'm still having a devil of a time getting my script to work
cross-platform.

I'm going to work on it for another day or so, but I think I'll be posting
again on the best way to pass a downloadable file through a PHP script.

.tony

On 10/17/03 8:47 PM, "Anthony Baratta" <anthony at baratta.com> wrote:

> At 03:44 PM 10/17/2003, Tony Grimes wrote:
>> I've got a PHP download script that sends a file to the browser, but while
>> it's downloading, the browser displays something like "25K of ?". Is there a
>> way of telling the browser how big the file is?
> 
> 
> 
>>     // Give it a name.
>>     header("Content-Disposition: attachment; filename=file.doc");
> 
> Tony....
> 
> $FileSize = filesize('/path/to/file.doc');
> header("Content-Disposition: attachment; filename=file.doc; size=$FileSize;");
> 
> Hope that helps.
> ---
> Anthony Baratta
> President
> Keyboard Jockeys
> 
> "Conformity is the refuge of the unimaginative."



More information about the thelist mailing list