ZF-7851: Call to Zend_Form_Element::receive() and then Zend_Form::getValues causes Zend_Validate_File_Count to count 2 files

Issue Type: Bug Created: 2009-09-15T16:18:47.000+0000 Last Updated: 2009-09-27T01:18:50.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Duo Zheng (duoduo) Assignee: Thomas Weidner (thomas) Tags: - Zend_Form

  • Zend_Validate_File

Related issues: Attachments:


Zend_Validate_File_Count shows an error prematurely like this: "Too much files, maximum '1' are allowed but '2' are given"

This can be done in 2 ways

  1. Call Zend_Form_Element::receive() then call Zend_Form->getValues()
  2. Call Zend_Form->getValues twice

What happens is the first call adds the temporary file path to Zend_Validate_File_Count /tmp/phpwlAZqc

The second call adds the real file name /tmp/picture.jpg

I do understand that getValues tries to process the form, but should I not be able to call it twice on the same instance? Or sometimes you want to check of the file was received first with Zend_Form_Element::receive() then collect the form data with Zend_Form->getValues(). If it shouldn't something should be done about multiple calls. Took a while to track this down.

Reproducible code below.

<pre class="highlight">
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(dirname(__FILE__) . '/../../library'),

/** Zend_Loader_Autoloader */
require_once 'Zend/Loader/Autoloader.php';
//automatically registers Zend

$form = new Zend_Form();
$file = new Zend_Form_Element_File('picture');
// ensure only 1 file
$file->addValidator('Count', true, 1);

$submit = new Zend_Form_Element_Submit('save');

if($form->isValid($_POST) && $form->picture->receive()){
    var_dump($form->getValues()); //THIS CAUSES THE COUNT ERROR

echo $form->render(new Zend_View());


Posted by Duo Zheng (duoduo) on 2009-09-15T16:22:40.000+0000

Added some additonal information

Posted by Thomas Weidner (thomas) on 2009-09-27T01:18:50.000+0000

There is a logical description for this irritation: Before the file has been uploaded, it is physically not available. Therefor it is counted with the temporary name.

After the upload, it is physically available, and the real name is counted.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.