in reply to Check that a value has been assigned to a variable when uploading a photo
The line "if ( !$filename )" seems to check the size of the uploaded file and apparently works well.That's not really what's happening there. If the size of the file being uploaded is greater than $CGI::POST_MAX then CGI will abort the process altogether and all params will be empty, so $filename will be empty. If no file has been selected for uploading, $filename will be empty then also.
if ( !$filename ) does perform the test you require - it is saying "if $filename is empty" (or rather, if $filename does not contain a true value) then return the error message.
You can check if an attempt to upload too big a file was made by using the cgi_error() function:
$error would contain the message "413 Request entity too large"my $error = $q->cgi_error; if ($error) { # return an error message }
Also, you are not checking if $AccountID has a value - you can check that the same way: if ( !$AccountID ) { # return an error message }
|
|---|