我需要你的帮助。我尝试使用Zend Framework 2创建表单上传,并按照here的说明,返回allways echo "failed";
并且文件不想切换到预定位置。
这是我的代码:
$nonFile = $request->getPost()->toArray();
$File = $this->params()->fromFiles('fileupload');
$data = array_merge_recursive(
$this->getRequest()->getPost()->toArray(),
$this->getRequest()->getFiles()->toArray()
);
if(!empty($data['fileupload']['name'])){
$size = new Size(array('min'=>2000000));
$adapter = new \Zend\File\Transfer\Adapter\Http();
$adapter->setValidators(array($size), $File['name']);
if($adapter->isValid()){
$adapter->setDestination('./helpdesk');
if ($adapter->receive($File['name'])) {
echo "success ";
}else{
echo "failed";
}
}else{
echo "no upload file";
}
}
任何人都可以帮助我吗?我的代码有问题吗?