SystemAttachment.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\controller\system;
  12. use app\admin\model\system\SystemAttachment as SystemAttachmentModel;
  13. use app\admin\controller\AuthController;
  14. use service\SystemConfigService;
  15. use service\UploadService as Upload;
  16. /**
  17. * 附件管理控制器
  18. * Class SystemAttachment
  19. * @package app\admin\controller\system
  20. *
  21. */
  22. class SystemAttachment extends AuthController
  23. {
  24. /**
  25. * 编辑器上传图片
  26. * @return \think\response\Json
  27. */
  28. public function upload()
  29. {
  30. $res = Upload::image('upfile', 'editor/' . date('Ymd'));
  31. //产品图片上传记录
  32. $fileInfo = $res->fileInfo->getinfo();
  33. $thumbPath = Upload::thumb($res->dir);
  34. SystemAttachmentModel::attachmentAdd($res->fileInfo->getSaveName(), $fileInfo['size'], $fileInfo['type'], $res->dir, $thumbPath, 0);
  35. $info = array(
  36. "originalName" => $fileInfo['name'],
  37. "name" => $res->fileInfo->getSaveName(),
  38. "url" => '.' . $res->dir,
  39. "size" => $fileInfo['size'],
  40. "type" => $fileInfo['type'],
  41. "state" => "SUCCESS"
  42. );
  43. echo json_encode($info);
  44. }
  45. public function index($action)
  46. {
  47. $CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents("system/plug/ueditor/php/config.json")), true);
  48. $CONFIG['imageUrlPrefix'] = SystemConfigService::get('uploadUrl');
  49. switch ($action) {
  50. case 'config':
  51. $result = json_encode($CONFIG);
  52. break;
  53. /* 上传图片 */
  54. case 'uploadimage':
  55. /* 上传涂鸦 */
  56. case 'uploadscrawl':
  57. /* 上传视频 */
  58. case 'uploadvideo':
  59. /* 上传文件 */
  60. case 'uploadfile':
  61. $result = json_encode([]);
  62. break;
  63. /* 列出图片 */
  64. case 'listimage':
  65. $result = json_encode([]);
  66. break;
  67. default:
  68. $result = json_encode(array(
  69. 'state' => '请求地址出错'
  70. ));
  71. break;
  72. }
  73. return $result;
  74. }
  75. }