private function _doUpload($res, $type) { $config = WebUtils::getMobcentConfig('misc'); $path = $config['apnsCertfilePath']; $certfileAPNs = $path . '/' . $config['apnsCertfileName']; if ($type == 'add_certfile_apns') { $password = (string) $_POST['passphrase']; if (UploadUtils::makeBasePath($path)) { if (!empty($_FILES) && count($_FILES) && is_uploaded_file($_FILES['file']['tmp_name']) && !$_FILES['file']['error']) { FileUtils::saveFile($certfileAPNs, file_get_contents($_FILES['file']['tmp_name'])); AppbymeConfig::setAPNsCertfilePassword($password); } else { $res = $this->makeErrorInfo($res, WebUtils::t('上传失败')); } } } else { if ($type == 'del_certfile_apns') { FileUtils::safeDeleteFile($certfileAPNs); } } return $res; }
private function _uploadMobcentImage($res, $attachment) { $savePath = $this->_getSavePath('image'); if (!empty($savePath)) { $urlFileName = $this->_getPathFileName('image', $attachment['name']); $fileName = $savePath . '/' . $urlFileName['file']; if (FileUtils::saveFile($fileName, $attachment['data']) != false) { // 添加水印 Yii::import('application.components.discuz.source.class.class_image', true); $image = new Mobcent_Image(); if ($image->param['watermarkstatus']['forum'] > 0) { $image->makeWatermark($fileName, '', 'forum'); } $res['urlName'] = $this->_getUrlFileName($urlFileName['path'], basename($fileName)); $res['id'] = 0; } } return $res; }