Save.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | 保存图片的几个方法
  5. |--------------------------------------------------------------------------
  6. */
  7. namespace Upload\Src;
  8. use Dever;
  9. use Upload\Src\Store\Local as Handle;
  10. class Save
  11. {
  12. public function __construct()
  13. {
  14. $image['file'] = Dever::input('file');
  15. $image['key'] = Dever::input('key');
  16. //file_put_contents(DEVER_PATH . 'web/data/upload.txt', var_export($image, true));
  17. $handle = new Handle($image);
  18. $this->output = $handle->copy($image);
  19. unset($this->output['file']);
  20. }
  21. public function action_api()
  22. {
  23. return $this->output;
  24. }
  25. public function start_api()
  26. {
  27. return $this->output;
  28. }
  29. public function drag_api()
  30. {
  31. if ($this->output['status'] == 1) {
  32. $this->output['filename'] = $this->output['url'];
  33. } else {
  34. $this->output['error'] = $this->output['message'];
  35. }
  36. Dever::outDiy($this->output);
  37. }
  38. public function ueditor_api()
  39. {
  40. if ($this->output['status'] == 1) {
  41. $this->output['state'] = 'SUCCESS';
  42. $this->output['original'] = 1;
  43. } else {
  44. $this->output['url'] = '';
  45. $this->output['fileType'] = 1;
  46. $this->output['original'] = 1;
  47. $this->output['state'] = $this->output['message'];
  48. }
  49. Dever::outDiy($this->output);
  50. }
  51. public function simditor_api()
  52. {
  53. if ($this->output['status'] == 1) {
  54. $this->output['state'] = true;
  55. } else {
  56. $this->output['state'] = false;
  57. }
  58. $this->output['file_path'] = $this->output['url'];
  59. Dever::outDiy($this->output);
  60. }
  61. }