function fillpdf_forms_submit in FillPDF 6
Creates a new Form from the uploaded PDF, including parsed fields
File
- ./
fillpdf.admin.inc, line 187 - Allows mappings of PDFs to site content
Code
function fillpdf_forms_submit($form, &$form_state) {
$dir = file_directory_path() . "/fillpdf";
// $validators not working, so I just checked manually in fillpdf_forms_validate()
$validators = array(
'file_validate_extensions' => array(
'pdf',
),
);
if ($file = file_save_upload('upload_pdf', $validators, $dir, FILE_EXISTS_REPLACE)) {
drupal_set_message('<strong>' . $file->filename . '</strong> was successfully uploaded');
file_set_status($file, FILE_STATUS_PERMANENT);
}
else {
drupal_set_message('Error saving file to ' . $dir, 'error');
}
db_query("INSERT INTO {fillpdf_forms} (title, url) VALUES('%s', '%s')", $file->filename, $file->filepath);
$fid = db_last_insert_id('fillpdf_forms', 'fid');
fillpdf_parse_pdf($fid);
$form_state['redirect'] = "admin/content/fillpdf/{$fid}";
}