For quite some time I have had a variety of scripts doing file uploads from a variety of browsers. Today I ran into a problem when using AOL Explorer. This runmode is taken form a CGI::Application application, and I find that when I look at the value of $filename at the end of the method, it has the FULL original file name including the Windoze path.
Obviously I have to modify the REGEX I am using to clean up the filename, but how do I come up with one that will work for all browsers?sub landingpage_template_upload_graphic { my $self = shift; my $page = $self->_gen_pgwrapper(); my $q = $self->query; $dir = "/home/finc/www/content/sts/images/campaigns/"; my $filename; my $filehandle; if ( $filename = $q->param('image') ) { if ( $filename =~ /^([\w-]+\.(jpg|gif|png|jpeg))$/ ) { $filehandle = $filename; $filename = $1; open( OP, ">$dir/$filename" ) or die "$!"; chmod 0777, "$dir/$filename"; binmode OP; my $buffer; my $bytesread; while ( $bytesread = read( $filehandle, $buffer, 1024 ) ) { print OP $buffer; } close $filehandle; } } #} $page->param( 'warning' => Dumper($q) . "\nName: $filename\nDirector +y: $dir\n" ); return $page->output(); }
In reply to CGI upload script problem with Explorer. by jdtoronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |