I have an upload script that is really bugging me. I can upload files up to 52k, but anything higher gives me an error. Any ideas what might be wrong? Here is my code:
#!C:\perl\bin\perl.exe -w $| = 1; use CGI qw(:standard); $cgi = new CGI; $path = "c:\\windows\\desktop"; print<<EOT; <CENTER><TABLE width="766" border="0" cellspacing="0" cellpadding="0"> <TR><TD colspan="4"><b>The following files were uploaded:<BR>&nbsp;</b +></TD></TR> <TR bgcolor="black"> <TD>&nbsp;&nbsp;&nbsp;</TD> <TD><FONT color="white"><B>FILE:</B></FONT></TD> <TD><FONT color="white"><B>DETAILS:</B></FONT></TD> <TD><FONT color="white"><B>STATUS:</B></FONT></TD> </TR> EOT # Get the form data $file1 = $cgi->param('file1'); $file2 = $cgi->param('file2'); $file3 = $cgi->param('file3'); $file4 = $cgi->param('file4'); $file5 = $cgi->param('file5'); $file6 = $cgi->param('file6'); $file7 = $cgi->param('file7'); $file8 = $cgi->param('file8'); $file9 = $cgi->param('file9'); $file10 = $cgi->param('file10'); $file11 = $cgi->param('THUMBNAIL_PHOTO'); $file12 = $cgi->param('LARGE_PHOTO'); $file13 = $cgi->param('FLYER_URL'); #directory you want to upload to $dir = "c:/windows/desktop"; push @files, ($file1,$file2,$file3,$file4,$file5,$file6,$file7,$file8, +$file9,$file10,$file11,$file12,$file13); foreach $file (@files) { if ($file ne "") { $name=$file; $name =~ s/.:\\.*\\//; if (-e "c:\\windows\\desktop\\$name") { $file =~ s/.:\\.*\\//; $file = uc($file); print<<EOT; <TR> <TD>&nbsp;</TD> <TD valign="top"> <B><FONT color=#000080>$file</FONT></B> </TD><TD></TD><TD> <B><FONT color="red">UPLOAD FAILED!*</FONT></B><P> </TD></TR> EOT $failed = "1"; open (LOGFILE, ">>c:\\windows\\desktop\\logfile.html") || die "Can +'t open log file"; $name = uc($name); print LOGFILE "<TR><TD colspan=5><CENTER><b>$name <font color=red> +UPLOAD FAILED</b></font><CENTER></TD></TR>"; close(LOGFILE); } else { #file_type not necessary but can be useful info #if your wanting to limit uploads to a certain #type of file $file_type = $cgi->uploadInfo($file)->{'Content-Type'}; #directory you want to upload to $dir = "c:/windows/desktop"; $file=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filenam +e $name = $2; #My understanding gets real iffy from here on in #however it does work in the exact format below open(LOCAL, ">$dir/$name") or die $!; #open file undef $bytesread; undef $buffer; # binmode is only necessary on win32 servers but #it won't hurt with unix so might as well leave it binmode LOCAL; while ($bytes = read($file,$buffer,1024)) { $bytesread += $bytes; print LOCAL $buffer; } close($file); close(LOCAL); chmod(0666,"$dir\/$name"); #$bytesread holds the value of the size of the #file in bytes. Useful if you want to restrict #size of uploaded files $file =~ s/.:\\.*\\//; $file = uc($file); print "<TR><TD>&nbsp;&nbsp;&nbsp;</TD><TD><font color=#000080><b>$file +</b></font></b></TD><TD><b> ($file_type, $bytesread bytes)</b></TD><T +D><B>Successfully Uploaded</B></TD></TR>\n"; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time +); $min=sprintf("%02d", $min); $sec=sprintf("%02d", $sec); } } } if ($failed eq "1") { print "<TR><TD colspan=5>* A file with the same name already exists. +Please rename the file and try again.</TD></TR>"; } print<<EOT; </TABLE></CENTER> EOT }

In reply to 52K maximum file upload? by Stamp_Guy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.