public function addAction() { $specId = $this->_getParam('id',0); $files = new File_Models_FileMapper(); $errorMsg = null; $fileForm = new File_Forms_FileSave(); $fileForm->setAttrib('enctype', 'multipart/form-data'); $specs = new General_Models_SpecMapper(); $arraySpecs = $specs->fetchAll(); $spec = new General_Models_Spec(); $specs->findSpec($specId,$spec); if($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if($fileForm->isValid($formData)) { if($fileForm->fileUpload->receive()) { $file = new File_Models_File(); $files = new File_Models_FileMapper(); $size = $fileForm->fileUpload->getFileSize(); //size $fullName = $fileForm->fileUpload->getFileName();//name $arr = explode('/',$fullName); $fileName = end($arr); $arr2 = explode('.',$fileName); $fName = $arr2[0]; //displayName $type = $arr2[1]; $userId = $this->getUserId(); $users = new System_Models_UserMapper(); $contactId = $users->getContactId($userId); //contactId $file->setName($fullName); $file->setDisplay($fName); $file->setSize($size); $file->setSpecId($specId); $file->setEdition($fileForm->getValue('edition')); $file->setContactId($contactId); $file->setInFlag($fileForm->getValue('inFlag')); $file->setProjFlag(0); $file->setProjectId(0); $file->setStatus($fileForm->getValue('status')); $file->setParent($fileForm->getValue('parent')); $file->setRemark($fileForm->getValue('remark')); $file->setType($type); $files->save($file); $this->_helper->flashMessenger->addMessage('文件上传成功。'); $this->_redirect('/file/index/index/id/'.$specId); } } } $this->view->spec = $spec; $this->view->specId = $specId; $this->view->arraySpecs = $arraySpecs; $this->view->errorMsg = $errorMsg; $this->view->fileForm = $fileForm; }