Пожалуйста, найдите решение, которое, я думаю, поможет вам
<?php
class Test_Form_ItemCreate extends Zend_Form {
public function init() {
$this->setAction('/test/item/create')
->setMethod('post');
$name = new Zend_Form_Element_Text('SellerName');
$name->setLabel('Name:')
->setOptions(array('size' => '35'))
->setRequired(true)
->addFilter('StringTrim');
//handling images..
$images = new Zend_Form_Element_File('images');
$images->setMultiFile(3)
->addValidator('IsImage')
->addValidator('Size', false, '204800')
->addValidator('Extension', false, 'jpg,png,gif')
->addValidator('ImageSize', false, array(
'minwidth' => 150,
'minheight' => 150,
'maxwidth' => 150,
'maxheight' => 150
))
->setValueDisabled(true);//the value will not be available.. while checking the file is valid or not.this is very important
// attach element to form
$this->addElement($images);
$this->addElement($name);
}
}
class Test_ItemController extends Zend_Controller_Action {
public function createAction() {
// generate input form
$form = new Test_Form_ItemCreate;
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
if ($form->isValid($this->getRequest()->getPost())) {
//moving of files if it is valid only
$form->images->setDestination('/tmp/uploads');
$adapter = $form->images->getTransferAdapter();
for ($x = 0; $x < $form->images->getMultiFile(); $x++) {
$xt = @pathinfo($adapter->getFileName('images_' . $x . '_'), PATHINFO_EXTENSION);
$adapter->clearFilters();
$adapter->addFilter('Rename', array(
'target' => sprintf('%d_%d.%s', $id, ($x + 1), $xt),
'overwrite' => true
));
$adapter->receive('images_' . $x . '_');
}
$this->_helper->getHelper('FlashMessenger')->addMessage('Your submission has been accepted as item #' . $id . '. A moderator will review it and, if approved, it will appear on the site within 48 hours.');
$this->_redirect('/test/item/success');
}
}
}
}
Обратите внимание на setValueDisabled (true) в Test_Form_ItemCreate