Download file size pregress bar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wagon

    #1

    Download file size pregress bar

    I currently use a php script to allow for downloads of a program i
    wrote. Some people have complained that there file browsers are
    unable to determine the file size (14 meg) so that they do not know
    how long it will take to download ( the browser says file size
    unknown) Is there a way in pohp to tellthe browser the file size so
    that it can produce the progresss bar on the download?
  • Andy Hassall

    #2
    Re: Download file size pregress bar

    On 15 Nov 2005 16:24:09 -0600, wagon <wagon@hotmail. com> wrote:
    [color=blue]
    >I currently use a php script to allow for downloads of a program i
    >wrote. Some people have complained that there file browsers are
    >unable to determine the file size (14 meg) so that they do not know
    >how long it will take to download ( the browser says file size
    >unknown) Is there a way in pohp to tellthe browser the file size so
    >that it can produce the progresss bar on the download?[/color]

    http://www.w3.org/Protocols/rfc2616/....html#sec14.13
    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    • wagon

      #3
      Re: Download file size pregress bar

      THANKX


      I assume it is the Content-Length: . What is the conversion for 14.9
      megabytes?

      Hate to be a pOn Tue, 15 Nov 2005 22:25:55 +0000, Andy Hassall
      <andy@andyh.co. uk> wrote:
      [color=blue]
      >On 15 Nov 2005 16:24:09 -0600, wagon <wagon@hotmail. com> wrote:
      >[color=green]
      >>I currently use a php script to allow for downloads of a program i
      >>wrote. Some people have complained that there file browsers are
      >>unable to determine the file size (14 meg) so that they do not know
      >>how long it will take to download ( the browser says file size
      >>unknown) Is there a way in pohp to tellthe browser the file size so
      >>that it can produce the progresss bar on the download?[/color]
      >
      > http://www.w3.org/Protocols/rfc2616/....html#sec14.13[/color]

      Comment

      • Chung Leong

        #4
        Re: Download file size pregress bar

        As I've said a number of times, don't use a PHP script to serve
        downloads of large files. The reasons are:

        1) The web server can do it much more efficiently. Each instance of PHP
        takes up quite a lot of memory. There's also quite a lot of double
        copying as the data travels through different layers.

        2) The web server knows how to handle partial retrieval--needed for
        resuming interrupted downloads and quick navigation through large PDF
        files.

        3) Earlier versions of the Apache 2 SAPI module leaks memory, losing
        every byte output by PHP. A rapid sequence of multi-megabyte downloads
        will consume all available memory, leading to a server crash.

        Getting back to your original question, you need to send the
        Content-Length header.

        Comment

        • Andy Hassall

          #5
          Re: Download file size pregress bar

          On 15 Nov 2005 16:41:19 -0600, wagon <wagon@hotmail. com> wrote:
          [color=blue]
          >I assume it is the Content-Length: W[/color]

          Yep.
          [color=blue]
          >What is the conversion for 14.9 megabytes?[/color]

          Depends whether you work for a hard drive manufacturer, or live in the real
          world.

          1 megabyte = 1024 * 1024 bytes = 1048576 bytes.

          (If you're a pedant then you can call it a "mibibyte") .

          If you're actually reading from a file, use filesize() to get the size in
          bytes. If you send a Content-Length then you have to get it exactly right, else
          Bad Things probably happen.

          In case you're confused by the terminology in the standard, a "byte" and an
          "octet" are, for all intents and purposes, the same thing.
          --
          Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
          http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

          Comment

          Working...