1

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?

Thanks.

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

3

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'));
  • 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
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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