FileName.php 606 B

1234567891011121314151617181920212223242526
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /** @author Julio Montoya */
  4. /**
  5. * Class HTML_QuickForm_Rule_FileName
  6. */
  7. class HTML_QuickForm_Rule_FileName extends HTML_QuickForm_Rule
  8. {
  9. /**
  10. * @param $value array Uploaded file info (from $_FILES)
  11. * @param null $options
  12. * @return bool
  13. */
  14. public function validate($value, $options = null)
  15. {
  16. if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
  17. (!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
  18. return is_uploaded_file($elementValue['tmp_name']);
  19. } else {
  20. return false;
  21. }
  22. }
  23. }