The following uses the upload() function in CGI.pm >= 2.47.
HTML:
<form action="cgi-bin/uploader.pl" method="post" enctype="multipart/fo
+rm-data">
Perl:
my $image = upload_file( "file_to_upload.txt", "../incoming" );
sub upload_file
{
local $| = 1;
my( $filename, $path ) = @_;
my $file = $query->upload($filename); # the magic
open OUTPUT, "> $path/$filename" or die "$path/$filename - $!";
binmode $file;
binmode OUTPUT;
my $buffer;
while ( read( $file, $buffer, 64*2**10 ) )
{
print OUTPUT $buffer;
}
close OUTPUT;
close $file;
return( $filename );
}