我有允许用户上传文件的表单。从我的控制器中,我想获取带有文件名的路径。我正在使用 getFileName() 方法。但它给出了以下错误:
Message: Method getFileName does not exist
以下是我的控制器操作:
public function addAction()
{
$form = new Application_Form_Student();
$form->setAttrib('enctype', 'multipart/form-data');
$form->submit->setLabel('Add');
$this->view->form = $form;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$name = $form->getValue('name');
$email = $form->getValue('email');
$photo = $form->getValue('photo');
$location = $form->getFileName('photo');
$students = new Application_Model_DbTable_Students();
$students->addStudent($name, $email);
$this->_helper->redirector('index');
} else {
$form->populate($formData);
}
}
}