創建了一個表單並添加了一個字段以將圖像上載到服務器上的一個文件夾I通過打印檢查提交表單後的值值是做工精細它提供了上述的錯誤,而不是將數據保存到DB:ZF2調用未定義的方法Zend File Transfer Adapter Http :: setInputFilter()
我的控制器:
public function vouchersAction()
{
$vouchers = new VouchersForm();
$vouchers->get('submit')->setValue('Vouchers');
$request = $this->getRequest();
if ($request->isPost()) {
//echo '<pre>'; print_r($request);
//exit();
$vouchers = new Vouchers();
$vouchers = new \Zend\File\Transfer\Adapter\Http();
$vouchers->setDestination('C:\xampp\htdocs\reisesparer\public\images\coupons');
$vouchers->setInputFilter($vouchers->getInputFilter());
$vouchers->setData($request->getPost());
if ($vouchers->receive()) {
echo "The file has been uploaded!";
}
if ($vouchers->isValid()) {
$vouchers->exchangeArray($vouchers->getData());
$this->getVouchersTable()->saveVouchers($vouchers);
return $this->redirect()->toRoute('vouchers');
}
}
return array('vouchers' => $vouchers);
}
錯誤: Fatal error: Call to undefined method Zend\File\Transfer\Adapter\Http::setInputFilter()