1) Add enctype='multipart/form-data' into your add/add error forms
2) In sub parse before any other code add:
use CGI qw(:standard);
my $in = new CGI;
...and then insert the code to do the uploading in an if block so it is ignored if there is no file to upload (using $in->param('file_field') to grab the file).
Then under that add:
$in = undef;
Then that should leave you with the rest of the parse sub below which will run as normal....