FileName.php 682 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. *
  13. * @return bool
  14. */
  15. public function validate($value, $options = null)
  16. {
  17. if ((isset($elementValue['error']) && $elementValue['error'] == 0) ||
  18. (!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) {
  19. return is_uploaded_file($elementValue['tmp_name']);
  20. } else {
  21. return false;
  22. }
  23. }
  24. }