i was writing the code in parts ...
That's fine. Actually, it's a good strategy in general. I just wasn't sure what exactly you were expecting to happen... so I mentioned it...
This is so basic a need (move a file to server and unzip it in a specified folder), i thought that it was well covered ground.
Yes... in fact, it shouldn't be too hard. And I think you're pretty close to having it working. What seems to be the problem with your last attempt is that that untainting regular expression in
die "invalid dir" unless ($dir =~ m/^([a-zA-Z0-9]+)\z/);
is missing a slash in its character set [a-zA-Z0-9] — note you're validating a path. Maybe, you'll also want to add stuff like underscore, dash, etc. I.e. something like
die "invalid dir" unless ($dir =~ m/^([\/\w-]+)\z/);
(\w is short for "alphanumeric", i.e. alphabetic character, digit and underscore)
As you had it, your CGI script was most likely dying with an "invalid dir" message written to stderr, in case you had specified a path like /frog/dog/cat. So, nothing after that line in the script did execute... By default, the message would end up in the webserver's error log, but you change that by adding
use CGI::Carp 'fatalsToBrowser';
somewhere near the top of the CGI script. This would redirect fatal error messages to the browser, which is nice for debugging purposes (you might want to disable it again, once things are working...). Good luck.
In reply to Re^3: HTML Form and Perl
by almut
in thread HTML Form and Perl
by workman_m
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |