my $pdf_name = $cgi_query->param('event_pdf'); my $pdf = 'EventPDF'; if ($pdf_name){ #A file (supposedly a PDF) has been sent in the post data. Load it into $pdf for storage in events table binmode($pdf_name); while (<$pdf_name>){ $pdf .= $_; } $pdf = $db->quote($pdf); } my $mime_type; #(Not very robust) type checking for uploaded file. This is dependent on the browser behaving $mime_type = $cgi_query->uploadInfo($pdf_name)->{'Content-Type'} if $pdf_name; if ($mime_type){ return $self->display_error("Attached file is not a PDF\n") unless $mime_type eq 'application/pdf'; }