我在从Zend Framework2上传图片时遇到了问题它工作得很好但是现在它提出了一个问题"找不到文件"当我打印适配器,我需要有相同形式的2个文件上传器
这是我的控制器编码文件上传
$adapter = new \Zend\File\Transfer\Adapter\Http(); $files = $adapter->getFileInfo(); $mediaFileHttpPostName = 'attr_image';
$imageFile = $files[$mediaFileHttpPostName];
$adapter->setDestination('./public/media');
// $adapter->addValidator('Extension', false, array('jpge'), $mediaFileHttpPostName);
$adapter->addFilter('Rename',
array(
'target'=> './public/media/'.$imageFile['name'],
'overwrite'=>true),
$mediaFileHttpPostName);
if (!$adapter->isValid()){
$returnObject->errorMessage = $adapter->getMessages();
$returnObject->result = 0;
} else {
try {
$adapter->receive($mediaFileHttpPostName);
$returnObject->result = 1;
} catch (\Zend\Filter\Exception\InvalidArgumentException $e) {
$returnObject->errorMessage = $e->getMessage();
$returnObject->result = 0;
}
}
$resizeObj = new Imageresize('./public/media/'.$imageFile['name']);
$resizeObj -> resizeImage(400, 300, 'auto');
$resizeObj -> saveImage($_SERVER['DOCUMENT_ROOT'] .'/uploads/attraction/main_image/'.$imageFile['name'], 100);
$attra->setAttrImage($imageFile['name']);