I can't understand why that should work, but I tried it anyway and got the same results. Here is my code:
Code:
sub main {
# --------------------------------------------------------
local (%in) = &parse_form;
# We are processing the form.
if (keys %in != 0) {
if ($in{'File'}) {
&upload_file;
} else {
&process_form;
}
}
# Otherwise we are displaying the form (in site_html.pl).
else {
#if ($db_single_category) {
# my %is_valid = map { $_ => 1 } &category_list;
# $ENV{'HTTP_REFERER'} =~ s,/[^/]+\.[^/]+$,,;
# $ENV{'HTTP_REFERER'} =~ m,$build_root_url/(.+?)/?$,;
# $is_valid{$1} ? &site_html_add_form ($1) : &site_html_add_form ();
#}
#else {
&site_html_add_form ();
#}
}
}
sub upload_file {
# --------------------------------------------------------
if ($in{'File'}) {
my ($bytesread,$buffer);
open(OUTFILE, ">/home/allgamesfree/public_html/images/captures/temp/$in{'File'}");
while ($bytesread=read($in{'File'},$buffer,1024)) {
print OUTFILE $buffer;
}
close (OUTFILE);
}
delete $in{'File'};
&process_form;
}
sub process_form {
# --------------------------------------------------------
my ($key, $status, $line, $output);
# Check the referer.
if (@db_referers and $ENV{'HTTP_REFERER'}) {
$found = 0;
foreach (@db_referers) {
$ENV{'HTTP_REFERER'} =~ /$_/i and $found++ and last;
}
if (!$found) {
&site_html_add_failure ("Auto submission is not allowed in this directory. Please visit the site to add your entry.");
return;
}
}
# This will set system fields like Validated to their proper values.
foreach $key (keys %add_system_fields) {
$in{$key} = $add_system_fields{$key};
}
# Set date variable to today's date.
$in{$db_cols[$db_modified]} = &get_date;
open (ID, "<$db_links_id_file_name") or &cgierr("error in process_form. unable to open id file: $db_links_id_file_name. Reason: $!");
$in{$db_key} = <ID> + 1; # Get next ID number
close ID;
# Validate the form input..
$status = &validate_record(%in);
if ($status eq "ok") {
# Update the counter.
open (ID, ">$db_links_id_file_name") or &cgierr("error in get_defaults. unable to open id file: $db_links_id_file_name. Reason: $!");
flock(ID, 2) unless (!$db_use_flock);
print ID $in{$db_key}; # update counter.
close ID; # automatically removes file lock
# Print out the validate input to a "validation database" where it is stored until
# the admin decides to add it into the real database.
open (VAL, ">>$db_valid_name") or &cgierr("error in add_record. unable to open validate file: $db_valid_name. Reason: $!");
flock(VAL, 2) unless (!$db_use_flock);
print VAL &join_encode(%in);
close VAL; # automatically removes file lock
# Send the admin an email message notifying of new addition.
&send_email;
# Send the visitor to the success page.
&site_html_add_success;
}
else {
&site_html_add_failure($status);
}
}
The result of all that is no file upload and more field cannot be left blank errors. What am I doing wrong?