Hi,
I'm having real trouble with adding a file upload element to my form. 
Whenever I upload a file an  exception is thrown.  I finally made a very
simple test action which still fails:

  public function testAction()
  {
    $form = new Zend_Form;
    $form->setAction('/company/test/');
    $form->setMethod('POST');
    $form->addElement('file','testUpload');
    $form->addElement('submit','Submit');

    if ($this->getRequest()->isPost())
    {
      if ($form->isValid($_POST))
      {
        echo "Valid!";
      }
    }

    $this->view->form=$form;
  }


The form displays as you'd expect, but if I upload the 78kb image.jpg I get
an exception:


Error: "testUpload" not found by file transfer adapter

#0 /usr/home/mark/www/library/Zend/File/Transfer/Adapter/Abstract.php(566):
Zend_File_Transfer_Adapter_Abstract->_getFiles('testUpload')
#1 /usr/home/mark/www/library/Zend/Form/Element/File.php(426):
Zend_File_Transfer_Adapter_Abstract->isValid('testUpload')
#2 /usr/home/mark/www/library/Zend/Form.php(1987):
Zend_Form_Element_File->isValid('image.jpg', Array)
#3 /usr/home/mark/www/application/controllers/CompanyController.php(109):
Zend_Form->isValid(Array)
#4 /usr/home/mark/www/library/Zend/Controller/Action.php(503):
CompanyController->testAction()
#5 /usr/home/mark/www/library/Zend/Controller/Dispatcher/Standard.php(285):
Zend_Controller_Action->dispatch('testAction')
#6 /usr/home/mark/www/library/Zend/Controller/Front.php(934):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http))
#7 /usr/home/mark/www/application/bootstrap.php(94):
Zend_Controller_Front->dispatch()
#8 /usr/home/mark/www/pub/index.php(8): Bootstrap->runApp()
#9 {main}



I can see from this list that other people are using this fine, and I've
just upgraded to the latest ZF version, but I just can't make even this
trivial test case work.  My php.ini looks OK to me:
file_uploads = On
upload_tmp_dir = /tmp
upload_max_filesize = 2M

Can anyone see what I'm doing wrong, or what the issue could be?

Thanks,
Mark

-- 
View this message in context: 
http://www.nabble.com/Form_Element_File-problems-tp22558075p22558075.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to