奇怪的 Zend_Form_Element_File 行为 [英] odd Zend_Form_Element_File behavior

查看:30
本文介绍了奇怪的 Zend_Form_Element_File 行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单中有以下元素:

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);

如果我在视图中打印整个表单,则此字段工作正常.但是我有一些非常自定义的 HTML 用于显示,所以我在我的视图中回显每个表单元素:

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?>

这适用于其他领域.但是对于这个文件字段.Zend_Form 验证因消息文件附件"超出定义的 ini 大小而中断,但是我没有在我的帖子中包含任何文件上传,即使我这样做了,它仍然会出现相同的消息错误.

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.

有什么想法吗?

推荐答案

您是否使用了正确的 EncType?它应该是多部分/表单数据".如果不是,则文件元素的键可能不会放入 $_FILES 数组中,并且文件元素会将其解释为文件太大而无法上传到服务器.

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.

这篇关于奇怪的 Zend_Form_Element_File 行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆