Example #1
0
 /**
  * @param POSTFileAccess $file_obj
  * @return bool
  */
 public function validate(POSTFileAccess $file_obj, &$error_message)
 {
     $fileSize = $file_obj->getFileSize();
     if ($fileSize > $this->getMaxFileSizeBytes()) {
         $error_message = 'File size is too large';
         return false;
     }
     return true;
 }
 /**
  * @param POSTFileAccess $file_obj
  * @return bool
  */
 public function validate(POSTFileAccess $file_obj, &$error_message)
 {
     $allowed_mime_types_arr = $this->getAllowedMimeTypesArr();
     if (!in_array($file_obj->getMimeType(), $allowed_mime_types_arr)) {
         $error_message = 'Invalid file mimetype. Must be one of: ' . implode(', ', $allowed_mime_types_arr);
         return false;
     }
     return true;
 }
 /**
  * @param POSTFileAccess $file_obj
  * @return bool
  */
 public function validate(POSTFileAccess $file_obj, &$error_message)
 {
     $file_extension = strtolower($file_obj->getExtension());
     $allowed_extentions_arr = $this->getAllowedExtensionsArr();
     if (!in_array($file_extension, $allowed_extentions_arr)) {
         $error_message = 'Invalid file extension. Must be one of: ' . implode(', ', $allowed_extentions_arr);
         return false;
     }
     return true;
 }