SergioQ has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw ( fatalsToBrowser ); use File::Basename; $CGI::POST_MAX = 1024 * 5000; my $safe_filename_characters = "a-zA-Z0-9_.-"; my $upload_dir = "/var/www/example.com/htdocs/upload"; my $q = new CGI; my $filename = $q->param("filename"); my $cat = $q->param("cat"); if ( !$filename ) { saysOutput("No file selected"); exit; } my ( $name, $path, $extension ) = fileparse ( $filename, '..*' ); $filename = $name . $extension; $filename =~ tr/ /_/; $filename =~ s/[^$safe_filename_characters]//g; if ( $filename =~ /^([$safe_filename_characters]+)$/ ) { $filename = $1; } else { saysOutput("yikes"); exit; } my $out = ""; my $upload_filehandle = $q->upload("filename"); open ( UPLOADFILE, ">$upload_dir/$filename" ) or die "$!"; binmode UPLOADFILE; my $stat = "."; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE; # My function which handles all printing to the web browser saysOutput($stat);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why am I uploading nothing? $upload_filehandle appears to read nothing
by choroba (Cardinal) on Feb 12, 2022 at 19:54 UTC | |
by SergioQ (Scribe) on Feb 12, 2022 at 20:19 UTC | |
by SergioQ (Scribe) on Feb 12, 2022 at 20:23 UTC | |
|
Re: Why am I uploading nothing? $upload_filehandle appears to read nothing
by Corion (Patriarch) on Feb 13, 2022 at 00:02 UTC | |
|
Re: Why am I uploading nothing? $upload_filehandle appears to read nothing
by Anonymous Monk on Feb 13, 2022 at 11:01 UTC |