You are here

function _fillpdf_validate_upload in FillPDF 7.2

Same name and namespace in other branches
  1. 7 fillpdf.admin.inc \_fillpdf_validate_upload()
2 calls to _fillpdf_validate_upload()
fillpdf_forms_admin_validate in ./fillpdf.admin.inc
Makes sure the Upload was provided (want to validate .pdf here too)
fillpdf_form_edit_validate in ./fillpdf.admin.inc

File

./fillpdf.admin.inc, line 95
Allows mappings of PDFs to site content

Code

function _fillpdf_validate_upload($file) {

  // From includes/file.inc, line 634, but can't use that function because file
  // not an object yet
  if (!preg_match('/\\.pdf$/i', $file)) {
    return array(
      '#error' => TRUE,
      '#message' => t('Only PDF files are allowed'),
    );
  }

  // Directory exist or writeable?
  $dir = file_build_uri('fillpdf');
  file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
  return TRUE;
}