I'm fairly new to Zend Framework and I've encountered something strange, which I'm hoping somebody will be able to explain. Consider following code:
<? class Form extends Zend_Form
{
public function init()
{
$upload = new Zend_Form_Element_File('upload');
$this->addElement($upload);
}
}
if ($_POST)
{
$form = new Form();
var_dump($form->isValid($_POST));
$values = $form->getValues();
var_dump($_FILES, file_exists($_FILES['upload']['tmp_name']));
exit;
}
?>
<form method="post" enctype="multipart/form-data">
<input type="file" name="upload"/>
<input type="submit" name="submit"/>
</form>
If uploading any file the var_dump of $_FILES will output that the uploaded file doesn't exist. Comment the $form->getValues() line, and it's there. After investigating the issue - getValues renames the actual file (ie. /tmp/php/phpBUI9M3) to whatever was the name of the uploaded file, keeping it in the same folder (ie. /tmp/php/test.png). Why? I was under the impression that getValues shouldn't alter any data.
PHP: 5.2.17, Zend: 1.10.4
Thanks!