Okay, couldn't resist. Here's one that I have tweaked over the years:
sub uploader { $| = 1; #flush the output buffer my $sourcefile = $query->param('uploadimage'); #make sure your HTML + form tag uses enctype="multipart/form-data" my ($buffer, $bytes, $newfile); if ($sourcefile =~ /([\w .-]+)$/i) {; #strip off path stuff $newfile = $1; } else { return("bad"); #returns to main prog for error handling } $newfile =~ s/ //; open (OUTFILE, ">$directory/$newfile") or die "Cannot open $newfile +: $!"; binmode($sourcefile); binmode(OUTFILE); while ($bytes = read($sourcefile, $buffer, 1024)) { print OUTFILE $buffer; } close(OUTFILE) or die "Close:$!"; chmod (0666, "$directory/$newfile"); }
In reply to Re: File Upload
by bradcathey
in thread File Upload
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |