Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL | E_STRICT);
- set_include_path(
- dirname(__FILE__)
- . PATH_SEPARATOR . dirname(__FILE__) . '/application/library'
- . PATH_SEPARATOR . get_include_path()
- );
- include_once 'Zend/Loader.php';
- Zend_Loader::registerAutoload();
- $element = new Zend_Form_Element_File('foo');
- $element
- // ->setMultiFile(2)
- ->setLabel('Upload an image:')
- ->setDestination('d:\\temp')
- // ->addValidator('Count', false, 2)
- ->addValidator('Size', false, 1024*1024*1024) // bytes
- ->addValidator('Extension', false, 'jpg,png,gif')
- ;
- $form = new Zend_Form;
- $form->setAttrib('enctype', 'multipart/form-data') // file upload
- ->setMethod('post')
- ->addElement($element, 'foo')
- ->addElement('submit', 'submit')
- ;
- if (isset($_POST) && count($_POST))
- {
- // echo 'valid = ', (int)$form->isValid($_POST), "\n";
- if ($form->isValid($_POST))
- {
- print_r($element->getValue());
- }
- }
- $view = new Zend_View();
- echo $form->render($view);
Add Comment
Please, Sign In to add comment