You are here

function _fillpdf_validate_upload in FillPDF 7

Same name and namespace in other branches
  1. 7.2 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 225
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 = fillpdf_build_uri('fillpdf');
  file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  return TRUE;
}