Loading ...
Sorry, an error occurred while loading the content.

Re: Upload Progress

Expand Messages
  • Jeff Boes
    ... another ... seconds. ... length of the file. Is this ... Hmm. This is *almost* a FAQ, and the problem is: it s not possible. When your page submits a file
    Message 1 of 3 , Aug 1, 2000
    • 0 Attachment
      --- In perl-beginner@egroups.com, Agustinus Setijanto <agust.jkt@g...>
      wrote:
      > Hi everybody!
      >
      > I plan to make a kind of file-storage on the web, which could handle
      > file-uploading. While a file is being uploaded, I want to have
      another
      > window, showing the upload progress. So, in this window, I think I
      > should make it auto-refresh to a CGI script for, say every 10
      seconds.
      > The script will read the bytes received by the Unix server (using ls
      > -l command combined with cut and grep) and compare it with the total
      length of the file. Is this
      > possible? How do I open a second window using Perl script?
      >
      > TIA.

      Hmm. This is *almost* a FAQ, and the problem is: it's not possible.
      When your page submits a file to the server, the server (not your CGI
      script) is in control until the file is uploaded *entirely*. Then, and
      only then, your CGI script is invoked.

      A similar question is: how can I use a CGI script to limit the
      bandwidth used by uploaders? I can test the file size being uploaded,
      and cancel the upload, can't I?

      Sure, but by that time, the bandwidth is already gone. The file (all
      100 Meg of it) has made the trip onto your server, and the CGI script
      is testing the size of the resulting temporary file held by the
      server--NOT the size of the file on the user's hard drive.

      If you want to do something that interactive, CGI isn't the answer.
      You need to do something client-side, and that means most likely Java.
      You'd have to set up a connection between the Java program and a
      server-side program, and transmit packets while updating the display.
      It's just not worth it, IMO.
    • Jeff Boes
      ... length of the file. Is this ... Okay, now that I ve REALLY READ your message... While it s true that your uploading script won t receive control
      Message 2 of 3 , Aug 1, 2000
      • 0 Attachment
        --- In perl-beginner@egroups.com, Agustinus Setijanto <agust.jkt@g...>
        wrote:

        > The script will read the bytes received by the Unix server (using ls
        > -l command combined with cut and grep) and compare it with the total
        length of the file. Is this
        > possible? How do I open a second window using Perl script?
        >

        Okay, now that I've REALLY READ your message... <blush>

        While it's true that your uploading script won't receive control until
        the file is uploaded, it's possible that you could run another window
        which gets some information from the server on how the upload is
        progressing. This depends on how the server handles temp files, so I
        won't claim for a minute that this *will* work. The only way to create
        a new window is via a client-side command, which means Javascript. You
        could put a 'onSubmit' handler in the form, which opens a new window
        running the other progress-monitoring script.

        As I see it, the problem will be determining which file progress to
        report. If you have two users uploading at the same time, you'll need
        to do some very fancy coding to figure out which file is theirs IF the
        server is using temporary filenames to represent the upload.

        Therefore, I'll now admit that this is possible the way you've stated
        it, but I still don't think it's worth the trouble. For upload scripts
        I've written, it's been sufficient to pop up a Javascript window with
        static text saying, "When you press the OK button in this window, the
        upload will start. It may take a long time. Please be patient."
        Anything further is cute window-dressing, but probably more work than
        it's worth.
      Your message has been successfully submitted and would be delivered to recipients shortly.