Save.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php namespace Upload\Api;
  2. use Dever;
  3. use Upload\Lib\Util;
  4. use Upload\Lib\Save as Service;
  5. class Save
  6. {
  7. public function __construct()
  8. {
  9. $this->id = Dever::input('id', 'is_numeric', '上传规则错误', 1);
  10. $this->file = Dever::input('file', '!empty', '上传文件错误');
  11. $this->cate_id = Dever::input('cate_id', 'is_numeric', '上传分类', 1);
  12. $this->group_id = Dever::load(Util::class)->getGroup();
  13. $this->user_id = Dever::load(Util::class)->getUser();
  14. }
  15. public function act()
  16. {
  17. return Dever::load(Service::class)->init($this->id, $this->cate_id, $this->group_id, $this->user_id)->act($this->file);
  18. }
  19. public function wangEditor()
  20. {
  21. Dever::config('setting', ['output_app' => [], 'output' => [
  22. 'status' => ['errno', ['1' => 0, '2' => 1]],
  23. 'msg' => 'message',
  24. ]]);
  25. return $this->act();
  26. }
  27. public function avatar()
  28. {
  29. $uid = Dever::input('uid', 'is_numeric', '用户ID');
  30. return Dever::load(Service::class)->init($this->id, $this->cate_id, $this->group_id, $this->user_id)->act($this->file, 'jpg', $uid);
  31. }
  32. }