odd Zend_Form_Element_File behavior
Asked Answered
R

4

8

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?

Riviera answered 9/9, 2009 at 16:39 Comment(0)
I
11

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.

Inconceivable answered 10/9, 2009 at 11:38 Comment(1)
that was a foolish thing to do - in my case :pKarilla
A
0

Mmm if it says ini size, have you checked the upload_max_filesize directive in your php.ini?

Adrian answered 9/9, 2009 at 20:52 Comment(1)
yes it is currently set to 32 megs. Also, this error is occurring both when a file is being uploaded, and when no file is selectedRiviera
D
0

check the view of the form, maybe you are rendering the form partially, try to put this on the view of your form:

<?=$this->form?>

(this worked for me)

Deaconess answered 25/10, 2009 at 15:45 Comment(0)
P
0

only form?> will work fine with uploading any file. but problem occurs when we try to put partial form as : form->file ?>

form->file ?> it will always show error so try to implement full form and avoid putting elements of form.

Philippeville answered 27/7, 2011 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.