Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Trouble with browser file upload for large files

by vladb (Vicar)
on May 28, 2002 at 21:23 UTC ( [id://169916]=note: print w/replies, xml ) Need Help??


in reply to Trouble with browser file upload for large files

I'm not entirely sure if this would be the optimal solution in your case, but the way I think this might work is if you were to fork off a child process to handle the file writing part. This would allow you to free up the main process to finish rendering the page to the web client and thereby avoid the time out message.

The code might look something like this (not tested! :):
if (!fork) { # doing stuff in child process... # open your file handle here while (my $bytesread = read($filesource, my $buffer,1024)) { print OUTFILE $buffer; } # you could also write to a 'status' file and display that back to t +he client ;) exit; } print $cgi->header(); print "Your upload is in process... see this status.html page for the +status (changes every once in awhile :)\n"; exit;


_____________________
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+) +-.*)$/; $_=["ps -e -o pid | "," $2 | "," -v "," "];`@$_`?{print"+ $1"}:{print" +- $1"}&&`rm $1`; print$\;}

Replies are listed 'Best First'.
Re: Re: Trouble with browser file upload for large files
by Baz (Friar) on May 28, 2002 at 23:21 UTC
    I tried switching off output buffering by adding
    select(STDOUT); $| = 1;
    at the start of my code, and by putting
    print "."
    in the while loop (above) which is writing to the upload file. I though this would print dots during the course of the upload, but it doesn't, why not?
      try adding a newline:
      print ".\n";

      cLive ;-)

      --
      seek(JOB,$$LA,0);

        Unfortunately that didn’t work either...
        Even though I've turned off output buffering the browser isn't displaying the next page until the complete upload is complete....my code is as follows
        print $query->header(-Refresh=>'5;URL=http://baz.perlmonk.org/main.cgi +'); print $query->start_html("Submission Added");
        would the refresh be switching the buffering back on?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://169916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-28 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found