karmakidd2 has asked for the wisdom of the Perl Monks concerning the following question:

The title says it all! I am having a hard time uploading large text (over 5 meg) documents onto my server. Small documents upload correctly. The problem occurs for both Netscape and IE. I originally had set MAX_FILE_SIZE and MAX_DIR_SIZE but this didn't seem to do anything. some relevant code:
use strict; use CGI; my $q = new CGI; my $path = "/home/nobody/d2dReviewDatFiles/" . $project . "/"; my $newFile = $path . "allRecords.txt"; my $uploadedFile = $q->upload("file" ); open (NEWREF, ">$newFile"); binmode $uploadedFile; binmode NEWREF; while (<$uploadedFile>) { print NEWREF; } close (NEWREF);
Wathcing my /usr/tmp directory I notice that the temperorary CGI file being created stalls at a few hundred thousand k (size varies from aprox. 100000 to 550000) Eventually the browser quits with a 'The page cannot be displayed' message I originally was using CGI.pm version 2.46 but upgraded to the latest version (2.752) If anyone could help that'd be great!

Replies are listed 'Best First'.
Re: uploading large files with CGI.pm
by THRAK (Monk) on May 30, 2001 at 23:42 UTC
Re: uploading large files with CGI.pm
by petdance (Parson) on May 31, 2001 at 00:18 UTC
    I've never understood why people say "Title says it all!", and then write more about their problem. Does the title say it all, or doesn't it?

    Just sayin',
    xoxo,
    Andy

    %_=split/;/,".;;n;u;e;ot;t;her;c; ".   #   Andy Lester
    'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'.  #   http://petdance.com
    "hack";print map delete$_{$_},split//,q<   andy@petdance.com   >
    
Re: uploading large files with CGI.pm
by novitiate (Scribe) on May 31, 2001 at 22:13 UTC
    I have a funny feeling there is more relevant code to be posted here, but for starters:
    • -set $| to 1;
    • -use read instead of <> to grab the info n bytes at a time, like this
      while ($size = read($file,$data,1024)) { print SAVE $data || die "Could not print to $file"; $total_size += $size; }


    humbly,
    novitiate

    "...goodnight you princes of main(e)"  --The Cider House Rules