At 14:05 9/12/2005, [EMAIL PROTECTED] wrote:
>Message: 1
>Date: Sun, 11 Sep 2005 18:04:03 -0400
>From: "Charles Maier" <[EMAIL PROTECTED]>
>Subject: Upload shows no progress?!?!?
>To: "Perl-Win32-Web Mailing List \(Perl-Win32-Web Mailing List\)"
>        <perl-win32-web@listserv.ActiveState.com>
>Message-ID: <[EMAIL PROTECTED]>
>Content-Type: text/plain;       charset="us-ascii"
>
>I have a simple script that allows the simple upload of files to my
>client's server (via CGI.lib) and then I grab the file and process it.
>The problem is some of these files are quite large and the people behind
>their browser see nothing and some will not wait through the time
>necessary for the file to be sent fully.
>
>Has anyone else had to deal with this and did you find a solution??
>Perhaps a FTP server?? Modify the CGI.lib?? 
>
>TIA for any comments..
>
>Chuck

You can do this with both CGI.pm and Apache::Request.  

For CGI.pm you want to look for is upload_hook() in the docs.

For Apache::Request you want to look for UPLOAD_HOOK and HOOK_DATA.

I've done both CGI.pm and Apache::Request.  And you can find some examples out 
on the web.  The problem is that the code is fairly fiddly, and so each 
person's code looks, ummm, horrible, so you can rarely get a complete example.  
And that goes double for my own code!

Hook check list:
  - use one of the hook methods to identify one of your subroutines to be 
called as each 'block' of upload file data is read
  - that routine gets an object ref that has information inside it
  - if you arrange it, that routine also gets a ref to one of your 
objects/hashes where you can keep a running status
  - if you do more than one file, you have to detect switch to next upload file 
by looking at filename in object ref
  - you can get total size of form submission by getting CONTENT-LENGTH from 
headers (Apache) or environment variable
  - your progress measure is comparing total size against your running total 
bytes read that you accumulate as your hook routine is called.
  - you need to write the current status into somewhere that the progress 
display can read, either a file or other "session data" storage

Entirely separate from this is _how_ to display the progress bar.  I've done it 
two different ways.

You can use Javascript code in the form page, run it from the onsubmit handler, 
and before it permits the submit, have it open a new window to a different URL. 
 That URL is your progress display CGI and has headers to automatically refresh 
the window until the upload is done.

Another slicker way is to use the latest buzzword AJAX and update a progress 
bar display inside the same page as the upload form.  Gets oooo's and aahhh's 
but is tricky.

As I said, there _are_ a few examples in Perl out there for you to look at.  
Google will reward your diligence. 


_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Web@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to