Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

odd Zend_Form_Element_File behavior

I have the following element in my form:

$attachment = new Zend_Form_Element_File('attachment');
$attachment->setLabel('Attach File (2MB Max)');
$attachment->addValidator('Count', false, 1);
$attachment->addValidator('Size', false, 2048000);

If I print the entire form in the view, this field works fine. However I have some very custom HTML that I'm using for display, so I am echoing out each form element like this in my view:

<?=$this->form->attachment?>

This works fine for other fields. However for this file field. Zend_Form validation breaks with the message The file 'attachment' exceeds the defined ini size However I am not including any file upload in my post, and even if I do, it still errors with the same message.

Any ideas?

like image 253
Mark Avatar asked Sep 09 '09 16:09

Mark


1 Answers

Are you doing the right kind of EncType? It should be 'multipart/form-data'. If it's not, the file element's key might not be getting put in the $_FILES array and the file element interprets that as the file was too big to be uploaded to the server.

like image 80
smack0007 Avatar answered Oct 23 '22 11:10

smack0007