I am trying to write a script in Perl that will allow the user to upload a file. At the moment, it says that it is working, but it does not actually upload the file!
Her
As CanSpice pointed out, this question gives the answer:
#!/usr/bin/perl
use CGI;
my $cgi = new CGI;
my $dir = 'sub';
my $file = $cgi->param('file');
$file=~m/^.*(\\|\/)(.*)/;
# strip the remote path and keep the filename
my $name = $2;
open(LOCAL, ">$dir/$name") or print 'error';
my $file_handle = $cgi->upload('file'); // get the handle, not just the filename
while(<$file_handle>) { // use that handle
print LOCAL $_;
}
close($file_handle); // clean the mess
close(LOCAL); //
print $cgi->header();
print $dir/$name;
print "$file has been successfully uploaded... thank you.\n";enter code here