UploadController.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\controller;
  15. use app\common\service\UploadService;
  16. use Exception;
  17. use think\response\Json;
  18. /**
  19. * 上传文件
  20. * Class UploadController
  21. * @package app\adminapi\controller
  22. */
  23. class UploadController extends BaseAdminController
  24. {
  25. /**
  26. * @notes 上传图片
  27. * @return Json
  28. * @author 段誉
  29. * @date 2021/12/29 16:27
  30. */
  31. public function image()
  32. {
  33. try {
  34. $cid = $this->request->post('cid', 0);
  35. $result = UploadService::image($cid);
  36. return $this->success('上传成功', $result);
  37. } catch (Exception $e) {
  38. return $this->fail($e->getMessage());
  39. }
  40. }
  41. /**
  42. * @notes 上传视频
  43. * @return Json
  44. * @author 段誉
  45. * @date 2021/12/29 16:27
  46. */
  47. public function video()
  48. {
  49. try {
  50. $cid = $this->request->post('cid', 0);
  51. $result = UploadService::video($cid);
  52. return $this->success('上传成功', $result);
  53. } catch (Exception $e) {
  54. return $this->fail($e->getMessage());
  55. }
  56. }
  57. /**
  58. * @notes 上传文件
  59. * @return Json
  60. * @author dw
  61. * @date 2023/06/26
  62. */
  63. public function file()
  64. {
  65. try {
  66. $cid = $this->request->post('cid', 0);
  67. $result = UploadService::file($cid);
  68. return $this->success('上传成功', $result);
  69. } catch (Exception $e) {
  70. return $this->fail($e->getMessage());
  71. }
  72. }
  73. }