/** * @param $value array Uploaded file info (from $_FILES) * @param null $options * @return bool */ public function validate($elementValue, $maxSize) { if (!empty($elementValue['error']) && (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])) { return false; } if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { return true; } return $maxSize >= @filesize($elementValue['tmp_name']); }
/** * Checks if the given element contains an uploaded file of the right mime type * * @param array Uploaded file info (from $_FILES) * @param mixed Mime Type (can be an array of allowed types) * @access private * @return bool true if mimetype is correct, false otherwise */ public function validate($elementValue, $mimeType) { if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { return true; } if (is_array($mimeType)) { return in_array($elementValue['type'], $mimeType); } return $elementValue['type'] == $mimeType; }
/** * Checks if the given element contains an uploaded file of the filename regex * * @param array Uploaded file info (from $_FILES) * @param string Regular expression * @access private * @return bool true if name matches regex, false otherwise */ function _ruleCheckFileName($elementValue, $regex) { if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { return true; } return preg_match($regex, $elementValue['name']); }
/** * Checks if the element contains an uploaded file * * @access public * @return bool true if file has been uploaded, false otherwise */ public function isUploadedFile() { return HTML_QuickForm_file::_ruleIsUploadedFile($this->_value); }