我在尝试实现文件上传时收到此错误。
if ($request->isPost()) {
$form->setInputFilter($language->getInputFilter());
$nonFile = $request->getPost()->toArray();
$File = $this->params()->fromFiles('fileupload');
$data = array_merge(
$nonFile, array('fileupload' => $File['name'])
);
$form->setData($request->getPost());
if ($form->isValid()) {
$size = new Size(array('min' => 20));
$adapter = new \Zend\File\Transfer\Adapter\Http();
$adapter->setValidators(array($size), $File['name']);
if (!$adapter->isValid()) {
$dataError = $adapter->getMessages();
$error = array();
foreach ($dataError as $key => $row) {
$error[] = $row;
} //set formElementErrors
$form->setMessages(array('fileupload' => $error));
} else {
$adapter->setDestination(dirname(__DIR__) . '/module/Application/Lanuguage');
if ($adapter->receive($File['name'])) {
$data = $form->getData();
$language->populate($data);
$this->getEntityManager()->persist($language);
$this->getEntityManager()->flush();
echo ' upload ' . $language->fileupload;
}
}
return $this->redirect()->toRoute('admin_language');
}
}
现在,当我为 $dataError 进行转储时。我收到这条消息
数组([fileUploadErrorIniSize] => File '' 超出定义的 ini 大小)
我正在尝试上传一个 85 字节大小的文件。我的 php.ini 中的默认文件上传大小为 8M。