/**
  * 上传
  */
 public function uploadAction()
 {
     $file = $_FILES['filedata'];
     $data = array();
     if (empty($file['name'])) {
         return $this->json(false, $this->lang['file_upload_null'], false, false);
     }
     if (is_uploaded_file($file['tmp_name'])) {
         if ($file['size'] > $this->options['upload']['sizelimit']) {
             return $this->json(false, sprintf($this->lang['file_too_large'], $file['name'], $file['size']), false, false);
         }
         $mime = $this->_getMime($file);
         if ($enables = $this->_request->getParam('enables')) {
             if (!in_array($mime, $this->_enableMimes[$enables])) {
                 return $this->json(false, $this->lang['invalid_file_type'], false, false);
             }
         }
         $mod = $this->_request->getParam('mod', self::UPLOAD_ATTACHMENT);
         if (!in_array($mod, $this->_supportMod)) {
             $mod = self::UPLOAD_ATTACHMENT;
         }
         $fileId = $mod == self::UPLOAD_ATTACHMENT ? Dao_Td_Attachment_File::getFileId() : Dao_Td_Netdisk_File::getFileId();
         $path = $mod . '/' . substr($fileId, 0, 1);
         $filePath = $this->options['upload']['path'] . '/' . $path;
         if (!is_dir($filePath)) {
             mkdir($filePath, 0777, true);
         }
         $params = array('fileid' => $fileId, 'filename' => $file['name'], 'size' => $file['size'], 'type' => $mime, 'path' => $path, 'uniqueid' => $this->_user->uniqueId, 'orgid' => $this->_user->orgId);
         if ($mod == self::UPLOAD_NETDISK) {
             $params['folderid'] = $this->_request->getParam('folderid', '^root');
             /* @var $daoFile Dao_Td_Netdisk_File */
             $daoFile = $this->getDao('Dao_Td_Netdisk_File');
         } else {
             /* @var $daoFile Dao_Td_Attachment_File */
             $daoFile = $this->getDao('Dao_Td_Attachment_File');
         }
         $ret = $daoFile->createFile($params);
         if ($mod == self::UPLOAD_NETDISK && $ret == -1) {
             return $this->json(false, $this->lang['space_not_enough'], false, false);
         }
         if (!$ret) {
             return $this->json(false, sprintf($this->lang['file_upload_failure'], $file['name']), false, false);
         }
         $ret = @move_uploaded_file($file['tmp_name'], $filePath . '/' . $fileId);
         if (!$ret) {
             return $this->json(false, sprintf($this->lang['file_upload_failure'], $file['name']), false, false);
         }
         $data['fileid'] = $fileId;
         $format = $this->_request->getParam('format', 'json');
         if ($format == 'script') {
             $data['success'] = true;
             $data['message'] = 'success';
             return $this->script($data);
         } else {
             return $this->json(true, $this->lang['file_upload_success'], $data, false);
         }
     }
     $this->json(false, sprintf($this->lang['file_upload_failure'], $file['name']), false, false);
 }
 /**
  * 附件保存到网盘
  */
 public function saveAttachAction()
 {
     $post = $this->_request->getPost();
     // 获取附件信息
     /* @var $daoAttachment Dao_Td_Attachment_File */
     $daoAttachment = $this->getDao('Dao_Td_Attachment_File');
     $file = $daoAttachment->getFile(array('fileid' => $post['fileid']));
     $fileId = Dao_Td_Netdisk_File::getFileId();
     $params = array('uniqueid' => $this->_user->uniqueId, 'orgid' => $this->_user->orgId, 'fileid' => $fileId, 'folderid' => $post['folderid'], 'filename' => $file->fileName, 'size' => $file->size, 'path' => $file->path, 'type' => $file->type);
     // 创建网盘文件记录
     /* @var $daoFile Dao_Td_Netdisk_File */
     $daoFile = $this->getDao('Dao_Td_Netdisk_File');
     $existFile = $daoFile->existFile(array('uniqueid' => $this->_user->uniqueId, 'folderid' => $post['folderid'], 'attachfileid' => $post['fileid']));
     if ($existFile) {
         return $this->json(false, $this->lang['file_is_in_here']);
     }
     $ret = $daoFile->createFile($params);
     if ($ret == -1) {
         return $this->json(false, $this->lang['space_not_enough']);
     }
     if (!$ret) {
         return $this->json(false, $this->lang['save_failure']);
     }
     // 标记来自附件
     $daoFile->updateFile($this->_user->uniqueId, $fileId, array('isfromattach' => 1, 'attachfileid' => $post['fileid'], 'fromuniqueid' => $file->uniqueId));
     return $this->json(true, $this->lang['save_success']);
 }