CGI Upload in forked child-thread

Discussion in 'Perl Misc' started by Carsten Broschek, May 3, 2006.

  1. Hi!

    Is it possible to handle a file upload via CGI through a
    background-thread in order to show process-info? If the server reads
    complete request and stores data into temp-file, there would be no sense
    to fork the process?

    My idea
    1) send multipart
    2) create session, fork process
    3) parent writes html reponse "upload in process", with some meta-refresh
    4) child process reads file-handle and writes into file
    5) upload state is stored into session


    Thanks for comments.

    Carsten
     
    Carsten Broschek, May 3, 2006
    #1
    1. Advertising

  2. Carsten Broschek

    Guest

    Carsten Broschek <> wrote:
    > Hi!
    >
    > Is it possible to handle a file upload via CGI through a
    > background-thread in order to show process-info? If the server reads
    > complete request and stores data into temp-file, there would be no sense
    > to fork the process?


    You are right, I don't think there is much sense to fork a process, from
    what you describe, anyway.

    >
    > My idea
    > 1) send multipart
    > 2) create session, fork process
    > 3) parent writes html reponse "upload in process", with some meta-refresh


    I don't think the client will honor a meta-refresh until the client is done
    uploading the data. You would probably have to have the *client* do the
    "fork", which is a web-question (javascript? using "_blank" as the
    target?) not a perl one. But if it does do a refresh into a cgi script, it
    will cause the cgi-script to be run from scratch, not connect into the
    previous spawned process of the earlier cgi invocation (well, you could
    make that happen with a bit of work, but I don't see why you would need
    to.)

    > 4) child process reads file-handle and writes into file


    Why not have one process read the file-handle, write into a file,
    and send soothing messages to the client every 10K bytes of upload?
    Use CGI's upload hook. Of course, you would be at the mercy of your
    web-servers buffering, and the clients incremental rendering. But
    it seems to work for me as long as I keep it simple.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , May 3, 2006
    #2
    1. Advertising


  3. >> 4) child process reads file-handle and writes into file

    >
    > Why not have one process read the file-handle, write into a file,
    > and send soothing messages to the client every 10K bytes of upload?
    > Use CGI's upload hook. Of course, you would be at the mercy of your
    > web-servers buffering, and the clients incremental rendering. But
    > it seems to work for me as long as I keep it simple.
    >
    > Xho
    >

    Ok, the main question should be - is it possible to generate the
    http-response, before the file is uploaded. is there a a way to control
    the buffering?

    c.
     
    Carsten Broschek, May 4, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    8,768
    Sebastian Scheid
    Aug 25, 2005
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,199
    David Schwartz
    Dec 9, 2003
  3. Donn Cave
    Replies:
    2
    Views:
    524
    MrEntropy
    Jul 15, 2005
  4. Zbigniew Fiedorowicz

    Getting STDERR from forked child processes?

    Zbigniew Fiedorowicz, Feb 5, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    187
    Aaron Sherman
    Feb 5, 2004
  5. Moritz Karbach

    How to kill a forked child process...

    Moritz Karbach, Jun 17, 2005, in forum: Perl Misc
    Replies:
    11
    Views:
    472
    Moritz Karbach
    Jun 20, 2005
Loading...

Share This Page