I have a small problem with the Zend_Form_Element_File class
When I comment out
- Code: Select all
->setDestination(BASE_PATH."/../public/images")
- Code: Select all
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in path/libzend-framework-php/Zend/Controller/Dispatcher/Standard.php:248 Stack trace: #0 path/libzend-framework-php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 path/libzend-framework-php/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 path/libzend-framework-php/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #3 path/public/index.php(26): Zend_Application->run() #4 {main} Next exception 'Zend_Controller_Exception' with message 'Invalid controller specified (error)#0 path/libzend-framework-php/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 path/libzend-framework-php/Zend/Controller/Plugin/Broker.php on line 336
Zend form
- Code: Select all
$this->setAction("/admin/main")->setMethod("post");
$this->setAttrib('enctype', 'multipart/form-data');
$image = new Zend_Form_Element_File('image');
$image->setLabel('Image')
->setDestination(BASE_PATH."/../public/images")
->setRequired(false)
->addFilter('HtmlEntities')
->addFilter('StringTrim')
->addValidator('Count', false, 1)
->addValidator('Extension', false, 'jpg,jpeg,png,gif');
$image_alt = new Zend_Form_Element_Text('image_alt');
$image_alt->setLabel('Image alt text')
->setOptions(array('size' => '30'))
->setRequired(false)
->addValidator('Alnum')
->addFilter('HtmlEntities')
->addFilter('StringTrim');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit')
->setOptions(array('class' => 'submit'));
$this->addElement($image)
->addElement($image_alt)
->addElement($submit);
Controller
- Code: Select all
public function indexAction()
{
$form = new Admin_Form_Cvmain();
$this->view->form = $form;
$model = new model_name();
if($this->getRequest()->isPost()){
if($form->isValid($this->getRequest()->getPost())){
$values = $form->getValues();
if(empty($values['id'])){
$id = $model->insert($values);
}else{
$id = $model->update($data);
}
}
}
}
Any Please help