Guest User

Untitled

a guest
Feb 21st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL | E_STRICT);
  3.  
  4. set_include_path(
  5. dirname(__FILE__)
  6. . PATH_SEPARATOR . dirname(__FILE__) . '/application/library'
  7. . PATH_SEPARATOR . get_include_path()
  8. );
  9.  
  10. include_once 'Zend/Loader.php';
  11. Zend_Loader::registerAutoload();
  12.  
  13. $element = new Zend_Form_Element_File('foo');
  14. $element
  15. // ->setMultiFile(2)
  16. ->setLabel('Upload an image:')
  17. ->setDestination('d:\\temp')
  18. // ->addValidator('Count', false, 2)
  19. ->addValidator('Size', false, 1024*1024*1024) // bytes
  20. ->addValidator('Extension', false, 'jpg,png,gif')
  21. ;
  22.  
  23. $form = new Zend_Form;
  24. $form->setAttrib('enctype', 'multipart/form-data') // file upload
  25. ->setMethod('post')
  26. ->addElement($element, 'foo')
  27. ->addElement('submit', 'submit')
  28. ;
  29.  
  30. if (isset($_POST) && count($_POST))
  31. {
  32. // echo 'valid = ', (int)$form->isValid($_POST), "\n";
  33. if ($form->isValid($_POST))
  34. {
  35. print_r($element->getValue());
  36. }
  37. }
  38.  
  39. $view = new Zend_View();
  40. echo $form->render($view);
Add Comment
Please, Sign In to add comment