willjones has asked for the wisdom of the Perl Monks concerning the following question:
These flag operators didn't work as I expected. !-e and !-f actually got entered every time and the -d and -z blocks were never entered regardless of whether the file was valid, empty, non-existing or a directory.my $err=""; my $inputFileHandle = $cgi->param("FILE"); if ( -d <$inputFileHandle> ) { $err.="This is a directory.<br/>"; } if ( !-f <$inputFileHandle> ) { $err.="This is not a plain file.<br/>"; } if ( -z <$inputFileHandle> ) { $err.="This is a zero byte file.<br/>"; } if ( !-e <$inputFileHandle> ) { $err.="This is a non-existing file.<br/>"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error detection on CGI file upload attempts
by Corion (Patriarch) on Nov 25, 2008 at 18:42 UTC | |
|
Re: Error detection on CGI file upload attempts
by jeffa (Bishop) on Nov 25, 2008 at 18:44 UTC |