SystemAttachment.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\admin\controller\system;
  3. use app\admin\model\system\SystemAttachment as SystemAttachmentModel;
  4. use app\admin\controller\AuthController;
  5. use crmeb\services\SystemConfigService;
  6. use crmeb\services\UploadService as Upload;
  7. /**
  8. * 附件管理控制器
  9. * Class SystemAttachment
  10. * @package app\admin\controller\system
  11. *
  12. */
  13. class SystemAttachment extends AuthController
  14. {
  15. /**
  16. * TODO 编辑器上传图片
  17. */
  18. public function upload()
  19. {
  20. $res = Upload::getInstance()->setUploadPath('editor/'.date('Ymd'))->image('upfile');
  21. if(is_array($res)){
  22. SystemAttachmentModel::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],0,$res['image_type'],$res['time']);
  23. $info["originalName"] = $res['name'];
  24. $info["name"] = $res['name'];
  25. $info["url"] = $res['dir'];
  26. $info["size"] = $res['size'];
  27. $info["type"] = $res['type'];
  28. $info["state"] = "SUCCESS";
  29. if($res['image_type'] == 1) $info['url'] = sysConfig('site_url').str_replace('\\','/',$res['dir']);
  30. }else
  31. $info = array(
  32. "msg" => $res,
  33. "state" => "ERROR"
  34. );
  35. echo json_encode($info);
  36. }
  37. }