Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a file called "stream.ogg" which is, well, an internet radio station. If a user tries to download the file, it always appears as "210mb" no matter what OS they try to save it from.

I've got several other files for download, some are .zip, and some are .exe. When someone downloads a file, it says "unknown time remaining" or "unknown file size total" and I was wondering if I could get Apache to relay the total size to the client?

Other servers on the net do have this set up somehow with Apache, for example when downloading a linux distro from any website, it always knows how big the file is. (ex. 19 minutes remaining).

Can anyone help me with this please?


PS: Apache is the latest public release, PHP and scripts are enabled.

share|improve this question
up vote 3 down vote accepted

You need to send Content-Length header.

If a PHP script initiates the download, you can set the header with:

header('Content-Length: ' . filesize('/path/to/file.ogg'));
share|improve this answer
And filesize is in bytes? – U4iK_HaZe Oct 18 '11 at 22:14
Yes, the Content-Length header should be in bytes (a.k.a. octets), and filesize() returns the number of bytes. – xofer Oct 18 '11 at 22:18
Alright, thanks for the help. How would I do this if I had files for direct download, ie., not from a web browser but instead from a piece of software downloading the files for itself, and display a progress bar? Ah, nevermind. I'll work on that myself another time. Not important. – U4iK_HaZe Oct 18 '11 at 22:38
Have your software read the Content-Length header. :-) – xofer Oct 18 '11 at 23:32
Well, it's console based, and it will fetch resources from a server much like MingW setup does. It's not so important. – U4iK_HaZe Oct 19 '11 at 19:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.