Save.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 $id = null;
  8. public $file = null;
  9. public $cate_id = null;
  10. public $group_id = null;
  11. public $user_id = null;
  12. public function __construct()
  13. {
  14. $this->id = Dever::input('id', 'is_numeric', '上传规则错误', 1);
  15. $this->file = Dever::input('file', '!empty', '上传文件错误');
  16. $this->cate_id = Dever::input('cate_id', 'is_numeric', '上传分类', 1);
  17. $this->group_id = Dever::load(Util::class)->getGroup();
  18. $this->user_id = Dever::load(Util::class)->getUser();
  19. }
  20. public function act()
  21. {
  22. return Dever::load(Service::class)->init($this->id, $this->cate_id, $this->group_id, $this->user_id)->act($this->file);
  23. }
  24. public function wangEditor()
  25. {
  26. Dever::config('setting', ['output_app' => [], 'output' => [
  27. 'status' => ['errno', ['1' => 0, '2' => 1]],
  28. 'msg' => 'message',
  29. ]]);
  30. return $this->act();
  31. }
  32. public function avatar()
  33. {
  34. $uid = Dever::input('uid', 'is_numeric', '用户ID');
  35. return Dever::load(Service::class)->init($this->id, $this->cate_id, $this->group_id, $this->user_id)->act($this->file, 'jpg', $uid);
  36. }
  37. }