ZF-5090: $form->getValues() raises Warning when the form has Zend_Form_Element_File with setMultiFile
Description
The following code raises warning at the line of $form->getValues() and/or $element->getValue() whether or not when you upload files.
Warning: basename() expects parameter 1 to be string, array given in \your\library\Zend\Form\Element\File.php on line 600
I do not know the good workaround to get the file names.
<?php include_once 'Zend/Loader.php'; Zend_Loader::registerAutoload();
$element = new Zend_Form_Element_File('foo'); $element->setMultiFile(2) ->setDestination('d:\temp') ;
$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)) { echo 'value = ', print_r($form->getValues(), true); // **** $form->foo->getValue() raises Warning, too } }
$view = new Zend_View(); echo $form->render($view);
Comments
Posted by twk (twk) on 2008-11-28T04:22:32.000+0000
As a workaround, you can use $this->getFileName() to get a file names array.
Posted by Thomas Weidner (thomas) on 2008-11-28T11:30:33.000+0000
Fixed with r12938