Issues

ZF-11485: Zend_Form_Element_File validation failure on Iphone/Ipad

Description

(Sorry for my english)

On Iphone and Ipad, are not displayed by the browser!

If I want to validate a form, with a not required file element within,

I expect a successful validation, although the file element value is empty But the validation failed with the message : "File 'myfile' exceeds the defined ini size".

If I validate this form with an Iphone/Ipad, in PHP, the global var $_FILES will be an empty array, but the Zend_Validate_File_Upload validator, used by Zend_File_Transfert_Adapter_Http, will detect this as a oversized file upload failure.

To reproduce this error on firefox, we can create a simple form

=== $form = new Zend_Form(); $form->addElement('File', 'myfile'); $form->addElement('Submit', 'submit'); $form->setEnctype(Zend_Form::ENCTYPE_MULTIPART);

$form->setAction($targetUrl);

and use firebug to delete the element. And submit the form.

The target url must try to validate the form :

if($form->isValid($_POST)) { echo 'ok'; // Processing and exit } var_dump($form->getMessages());

Comments

One thing you can do in ZF >= 1.11 is use Zend_Http_UserAgent and check to see if the client supports xhtml_file_upload (which none of the iOS devices do, currently).

Check out the docs online for how to set it up: http://framework.zend.com/manual/en/…

Actually there is no way for Zend_File or Zend_Form to recognise if the attached agent supports file uploads or not

I see no way how an solution to this problem could be done when an i* agent behaves like an oversized upload

Feel free to reopen as soon as there is an solution on how this could be recognised

This issue is very bad...

Even the file element has setRequired(false), the form is not validated...