becool321 has asked for the wisdom of the Perl Monks concerning the following question:
#!I:\Interwoven\TeamSite\iw-perl\bin\iwperl -wT use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser set_message); set_message("It's not a bug, it's a feature!"); use Fcntl qw(:flock); use strict; print header, start_html(-title=>'Upload file to server'), =>h3('Upload local file from PC to teamsite'), start_multipart_form, 'Click on the browse button to choose a filename: ', filefield( -name => 'upfile', -size => 50, -maxlength => 80), hr, submit(-name=>'Upload File'), hr, end_form; my $file = param("upfile"); my $upload_dir = "Y:\\Test\\user\\videos\\"; my $fh; unless ( $file ) { print "Nothing uploaded?<p>\n"; } else { my $outfile = "$upload_dir".""; my ($safe_file_name) = $outfile =~ /([-\@:\/\\\w.]+)$/; if ($file =~ /swf/ || $file =~ /high/ || $file =~ /low/) { $outfile .= $file; #if (-e $outfile) { # error_msg("File already exist in destination folder"); #} } else { error_msg("Only '.swf' files and files with 'high' or 'low' in +the name will be uploaded."); } $safe_file_name = $1; if (!$safe_file_name) { die qq{Disallowed characters in file $safe_file_name\n}; } my $file_len = 0; open (my $fh, '>', $safe_file_name) or error_msg("Can't open $safe_file_name for writing: $!"); flock( $fh, LOCK_EX ); while ( read( $file, my $i, 1024 ) ) { print $fh $i; $file_len = $file_len + 1024; if ( $file_len > 1024000 ) { close($fh); error_msg("Error - file is too large. Save aborted.<p>"); } } close($fh); print "File: $file<br>\n"; print "Size: ", $file_len / 1024, "KB<br>\n"; print "Uploaded to: $safe_file_name<p>\n"; } print end_html; sub error_msg { my ($msg) = @_; print "<h2>Error</h2>\n"; print "$msg<p>\n"; exit; }
I'm getting "Disallowed characters in file"
...
I'm trying different methods with taint to find answer
so far no luck. I get error above or "Insecure dependency in open while running with -T switch" error
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Upload file through perl-cgi not working
by Anonymous Monk on Aug 23, 2011 at 02:54 UTC | |
by becool321 (Initiate) on Aug 23, 2011 at 05:05 UTC | |
|
Re: Upload file through perl-cgi not working
by MidLifeXis (Monsignor) on Aug 23, 2011 at 09:56 UTC | |
by Anonymous Monk on Aug 23, 2011 at 10:16 UTC | |
by becool321 (Initiate) on Sep 14, 2011 at 22:11 UTC |