【发布时间】:2016-10-05 12:58:58
【问题描述】:
我正在尝试使用 Zend Form 上传图像。由于我们需要它来移动图像,我想添加一个过滤器来完成这项工作。但我不能使用 getInputFilterChain(),我一直有这个致命错误:Call to undefined method Zend\InputFilter\InputFilter::getFilterChain()。我在这里想念什么?
我能够在 $prg 数组中获取文件信息。而正如我在https://framework.zend.com/manual/2.4/en/modules/zend.mvc.plugins.html 上看到的,这种方法应该存在于这里,不是吗?
如果我在我的 Form.php 文件中使用它,我会得到同样的错误。
提前感谢您的宝贵时间!
我的控制器动作:
public function signinAction()
{
$this->em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
$form = new SignupForm($this->em);
$form->getInputFilter()->getFilterChain()->attach(
new Zend\Filter\File\RenameUpload(array(
'target' => './data/tmpuploads/file',
'randomize' => true,
))
);
$model = new ViewModel(array("form" => $form));
$url = $this->url()->fromRoute("signin");
$prg = $this->fileprg($form, $url, true);
if($prg instanceof \Zend\Http\PhpEnvironment\Response){
return $prg;
}
else if($prg === false){
return $model;
}
//other stuff
...
}
【问题讨论】:
标签: php zend-framework zend-form