I am trying to upload a file in zend framework 2. public function uploadassgnAction(){ $form=new UploadForm('upload-form'); $tempFile = null; $prg = $this->fileprg($form); if ($prg instanceof \Zend\Http\PhpEnvironment\Response) { return $prg; } elseif (is_array($prg)) { if ($form->isValid()) { $data = $form->getData(); return $this->redirect()->toRoute('/authentication'); } else { $fileErrors = $form->get('image-file')->getMessages(); if (empty($fileErrors)) { $tempFile = $form->get('image-file')->getValue(); } } } return array( 'form' => $form, 'tempFile' => $tempFile, ); }
this is my function in controller which get data from form. here is the code of the form: <?php namespace Assignment\Form; use Zend\InputFilter; use Zend\Form\Element; use Zend\Form\Form; class uploadForm extends Form{ public function __construct($name = null, $options = array()) { parent::__construct($name, $options); $this->addElements(); $this->addInputFilter(); } public function addElements(){ $file = new Element\File('image-file'); $file->setLabel('Avatar Image Upload')->setAttribute('id', 'image-file'); $this->add($file); } public function addInputFilter() { $inputFilter = new InputFilter\InputFilter(); $fileInput = new InputFilter\FileInput('image-file'); $fileInput->setRequired(true); $fileInput->getFilterChain()->attachByName('filerenameupload', array( 'target' => '/usr/local/zend/tmp/waqas.png', 'randomize' => true, ) ); $inputFilter->add($fileInput); $this->setInputFilter($inputFilter); } } the file is uploaded to directory /usr/local/zend/temp/ but its not get redirected to the given route? -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/problem-in-Uploading-file-tp4660947p4660949.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com