ZF-4634: Zend_Form_Element_File - setMultiFile does not work

Description

If I want to use setMultiFile, it does not work -> error message: The file 'upload_file' was illegal uploaded, possible attack.

I think, that the problem is with the $_FILES to files-array conversion.

$_FILES:


array(1) {
  ["upload_file"] => array(5) {
    ["name"] => array(2) {
      [0] => string(23) "zend_framework_logo.jpg"
      [1] => string(23) "zend_framework_logo.png"
    }
    ["type"] => array(2) {
      [0] => string(10) "image/jpeg"
      [1] => string(9) "image/png"
    }
    ["tmp_name"] => array(2) {
      [0] => string(23) "I:\xampp\tmp\php388.tmp"
      [1] => string(23) "I:\xampp\tmp\php389.tmp"
    }
    ["error"] => array(2) {
      [0] => int(0)
      [1] => int(0)
    }
    ["size"] => array(2) {
      [0] => int(4353)
      [1] => int(25524)
    }
  }
}

converted array:


array(1) {
  ["upload_file"] => array(2) {
    ["destination"] => string(30) "I:\xampp\htdocs\webexpo\upload"
    ["validators"] => array(0) {
    }
  }
}

Comments

Please give reproducable code.

How the files are known internally has nothing to do with multifile. And the "converted array" does not show the internals of the file component.

Probably fixed with r12068. If we get no response until 23.10 we will close this issue as fixed.

Sorry, I didn't have time to reply earlier.

Problem happens when I have multifile element set as required.

Code for reproduction:


        $form = new Zend_Form();
        $form->setName('upload_form');
        $form->setMethod(Zend_Form::METHOD_POST);
        $form->setEnctype('multipart/form-data');

        $element = new Zend_Form_Element_File('upload_file');
        $element->setLabel('Upload:')->setRequired(true)
            ->setDestination('I:\xampp\htdocs\webexpo\upload');
        $element->setMultiFile(2);
        $form->addElement($element);
        
        $form->addElement(new Zend_Form_Element_Submit(array(
            'name' => 'Upload',
        )));

        $this->view->form = $form;
        
        if ($this->getRequest()->isPost()) {
            $valid = $form->isValid($this->getRequest()->getParams());
            echo $valid;
        }

Solved with r12082.

Just to mention: There were also notices returned which have had helped in solving this issue faster. Background: addValidator was not able to handle multifiles.

Changing issues in preparation for the 1.7.0 release.