/** * 上传项目文档 * */ public function uploaddocAction() { $projectid = $this->request->getGet('projectid'); $files = $this->request->files(); // 上传文件 $up = new QP_Upload_Upload(); $up->set(array('type' => '*', 'savePath' => SITEWEB_PATH . '/files/projectdocs/')); // 一次最多上传 5 个 for ($i = 1; $i <= 5; ++$i) { // 如果有文件上传 $inputname = 'docfile_' . $i; if ($up->setInputName($inputname)->hasUpload()) { // 得到上传后的文件名 $up->upload(); $filename = $up->getUploadFile(); // 如果没有设置文档名则用文件名 $docname = $this->request->getPost('docname_' . $i, ''); if ($docname == '') { $docname = $files[$inputname]['name']; } // 插入表 $sets = array('projectid' => $_POST['projectid'], 'docname' => $docname, 'docfile' => $filename, 'docsize' => $files[$inputname]['size'], 'dateline' => time()); $this->model->addDocs($sets); } } $this->jsCallBack('updocs_callback', 0); }
/** * 上传BUG文档 */ private function uploadDocs($bugid) { $files = $this->request->files(); // 上传文件 $up = new QP_Upload_Upload(); $up->set(array('type' => '*', 'savePath' => SITEWEB_PATH . '/files/bugdocs/')); // 一次最多上传 5 个 for ($i = 1; $i <= 5; ++$i) { // 如果有文件上传 $inputname = 'docfile_' . $i; if ($up->setInputName($inputname)->hasUpload()) { // 得到上传后的文件名 $up->upload(); $filename = $up->getUploadFile(); // 如果没有设置文档名则用文件名 $docname = $this->request->getPost('docname_' . $i, ''); if ($docname == '') { $docname = $files[$inputname]['name']; } // 插入表 $sets = array('docname' => $docname, 'docfile' => $filename, 'dateline' => time()); $this->bugModel->addBugDoc($sets, $bugid); } } }