This can also be done eaily in perl. The form gary uses would be the same except that the action would be the perl script instead.
The script uses the perl module CGI.pm. Here is sample code
#! /usr/bin/perl
use CGI qw/:standard/;
####################
#Global Variables
####################
$officeUsername ='test';
$officePassword = 'upload';
####################
print header,
start_html(-title=>'File Upload',
-bgcolor=>'#ffffff'),
h2('File Upload');
print_form() unless param; #print form if not filled out
print_results() if param; #process if form filled in
print end_html;
exit;
sub print_form {
print start_multipart_form,
"
Username: ",
textfield(-name=>'username', -size=>10),br,
" ",
"
Password:",
textfield(-name=>'password', -size=>10),
" ",
"
File to upload:",
filefield(-name=>'upload',-size=>20),
" ",
submit(-label=>'Upload File'),
end_form;
}
sub print_results {
my $length;
my $username = param('username');
my $password = param('password');
my $file = param('upload');
if(!$file && $username != $officeUsername && $password != $officePassword) {
print "No file uploaded. Username/password combination incorrect or no file chosen. Please try again.";
return;
}
#upload and save file
open (SAVE,">./saved_file.txt") || die $!;
while (<$file>) {
print SAVE $_;
}
close SAVE;
print h2('File: ',$file,' --Uploaded Successfully');
}