#!c:\perl\bin\perl.exe $| = 1; #Not sure what it does, but it works :) #starts the cgi.pm mod use CGI qw(:standard); $cgi = new CGI; #get the form data $file1 = $cgi->param('file1'); $file2 = $cgi->param('file2'); $file3 = $cgi->param('file3'); $file4 = $cgi->param('file4'); #directory you want to upload to $dir = "c:/windows/desktop"; push @files, ("$file1","$file2","$file3","$file4"); foreach $file (@files) { #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'}; $file=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filename $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"); print $cgi->header(); #prints the header stuff #$bytesread holds the value of the size of the #file in bytes. Useful if you want to restrict #size of uploaded files print "Successful Upload

File:$file ($file_type, $bytesread bytes)
\n"; } exit; #exit's script