Upload.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Index.php
  4. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  5. * =========================================================
  6. * Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
  7. * ----------------------------------------------
  8. * 官方网址: https://www.niushop.com
  9. * =========================================================
  10. * @author : niuteam
  11. * @date : 2022.8.8
  12. * @version : v5.0.0.1
  13. */
  14. namespace app\api\controller;
  15. use app\model\upload\Upload as UploadModel;
  16. /**
  17. * 上传管理
  18. * @author Administrator
  19. *
  20. */
  21. class Upload extends BaseApi
  22. {
  23. /**
  24. * 头像上传
  25. */
  26. public function headimg()
  27. {
  28. $upload_model = new UploadModel($this->site_id);
  29. $param = array (
  30. "thumb_type" => "",
  31. "name" => "file",
  32. "watermark" => 0,
  33. "cloud" => 1
  34. );
  35. $result = $upload_model->setPath("headimg/" . date("Ymd") . '/')->image($param);
  36. return $this->response($result);
  37. }
  38. /**
  39. * 评价上传
  40. */
  41. public function evaluateimg()
  42. {
  43. $upload_model = new UploadModel($this->site_id);
  44. $param = array (
  45. "thumb_type" => "",
  46. "name" => "file",
  47. "watermark" => 0,
  48. "cloud" => 1
  49. );
  50. $result = $upload_model->setPath("evaluate_img/" . date("Ymd") . '/')->image($param);
  51. return $this->response($result);
  52. }
  53. public function headimgBase64()
  54. {
  55. $upload_model = new UploadModel($this->site_id);
  56. $file = input('images', '');
  57. $file = base64_to_blob($file);
  58. $result = $upload_model->setPath("headimg/" . date("Ymd") . '/')->remotePullBinary($file[ 'blob' ]);
  59. return $this->response($result);
  60. }
  61. public function headimgPull()
  62. {
  63. $upload_model = new UploadModel($this->site_id);
  64. $path = input('path', '');
  65. $result = $upload_model->setPath("headimg/" . date("Ymd") . '/')->remotePull($path);
  66. return $this->response($result);
  67. }
  68. /**
  69. * 聊天图片上传
  70. */
  71. public function chatimg()
  72. {
  73. $upload_model = new UploadModel(0);
  74. $param = array (
  75. "thumb_type" => "",
  76. "name" => "file"
  77. );
  78. $result = $upload_model->setPath("chat_img/" . date("Ymd") . '/')->image($param);
  79. return $this->response($result);
  80. }
  81. }