Save.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. if ($image['file']) {
  18. $handle = new Handle($image);
  19. $this->output = $handle->copy();
  20. unset($this->output['file']);
  21. }
  22. }
  23. public function copy($file, $key = 1)
  24. {
  25. $image['file'] = $file;
  26. $image['key'] = $key;
  27. $handle = new Handle($image);
  28. $this->output = $handle->copy();
  29. unset($this->output['file']);
  30. return $this->output;
  31. }
  32. public function action_api()
  33. {
  34. Dever::outDiy($this->output);
  35. }
  36. public function start_api()
  37. {
  38. Dever::outDiy($this->output);
  39. }
  40. public function drag_api()
  41. {
  42. if ($this->output['status'] == 1) {
  43. $this->output['filename'] = $this->output['url'];
  44. } else {
  45. $this->output['error'] = $this->output['message'];
  46. }
  47. Dever::outDiy($this->output);
  48. }
  49. public function ueditor_api()
  50. {
  51. if ($this->output['status'] == 1) {
  52. $this->output['state'] = 'SUCCESS';
  53. $this->output['original'] = 1;
  54. } else {
  55. $this->output['url'] = '';
  56. $this->output['fileType'] = 1;
  57. $this->output['original'] = 1;
  58. $this->output['state'] = $this->output['message'];
  59. }
  60. Dever::outDiy($this->output);
  61. }
  62. public function simditor_api()
  63. {
  64. if ($this->output['status'] == 1) {
  65. $this->output['state'] = true;
  66. } else {
  67. $this->output['state'] = false;
  68. }
  69. $this->output['file_path'] = $this->output['url'];
  70. Dever::outDiy($this->output);
  71. }
  72. public function kindeditor_api()
  73. {
  74. if ($this->output['status'] == 1) {
  75. $this->output['error'] = 0;
  76. } else {
  77. $this->output['error'] = 1;
  78. $this->output['message'] = $this->output['message'];
  79. }
  80. $this->output['url'] = $this->output['url'];
  81. Dever::outDiy($this->output);
  82. }
  83. }