File.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // +---------------------------------------------------------------------+
  3. // | OneBase | [ WE CAN DO IT JUST THINK ] |
  4. // +---------------------------------------------------------------------+
  5. // | Licensed | http://www.apache.org/licenses/LICENSE-2.0 ) |
  6. // +---------------------------------------------------------------------+
  7. // | Author | Bigotry <3162875@qq.com> |
  8. // +---------------------------------------------------------------------+
  9. // | Repository | https://gitee.com/Bigotry/OneBase |
  10. // +---------------------------------------------------------------------+
  11. namespace app\home\controller;
  12. use app\common\logic\File as LogicFile;
  13. use app\home\logic\HomeBase;
  14. /**
  15. * 文件控制器
  16. */
  17. class File extends HomeBase
  18. {
  19. /**
  20. * 图片上传
  21. */
  22. public function pictureUpload()
  23. {
  24. $result = $this->logicFile->pictureUpload();
  25. return json($result);
  26. }
  27. /**
  28. * 文件上传
  29. */
  30. public function fileUpload()
  31. {
  32. $result = $this->logicFile->fileUpload();
  33. return json($result);
  34. }
  35. /**
  36. * 编辑器图片上传
  37. */
  38. public function editorPictureUpload()
  39. {
  40. $result = get_sington_object('fileLogic', LogicFile::class)->pictureUpload('imgFile');
  41. $data = false === $result ? [RESULT_ERROR => DATA_NORMAL, RESULT_MESSAGE => '文件上传失败'] : [RESULT_ERROR => DATA_DISABLE, RESULT_URL => get_picture_url($result['id'])];
  42. return throw_response_exception($data);
  43. }
  44. }