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!
Here is the code:
#!/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';
while(<$file>) {
print LOCAL $_;
}
print $cgi->header();
print $dir/$name;
print "$file has been successfully uploaded... thank you.\n";enter code here
You can use this code, will work properly.
CGI, besides lots of documentation, also comes with a lot of examples, see http://search.cpan.org/dist/CGI/MANIFEST
So combined with that knowledge, you can write
Your code shrinks when you switch to Dancer/Catalyst/Mojolicious
As CanSpice pointed out, this question gives the answer: