123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- /*
- |--------------------------------------------------------------------------
- | 保存图片的几个方法
- |--------------------------------------------------------------------------
- */
- namespace Upload\Src;
- use Dever;
- use Upload\Src\Store\Handle;
- class Save
- {
- public function __construct()
- {
- $image['file'] = Dever::input('file');
- $image['key'] = Dever::input('key');
-
- //file_put_contents(DEVER_PATH . 'web/data/upload.txt', var_export($image, true));
- if ($image['file']) {
- $handle = new Handle($image);
- $this->output = $handle->copy();
- unset($this->output['file']);
- }
- }
- public function copy($file, $key = 1)
- {
- $image['file'] = $file;
- $image['key'] = $key;
- $handle = new Handle($image);
- $this->output = $handle->copy();
- unset($this->output['file']);
- return $this->output;
- }
- public function copys($file, $key = 1)
- {
- $file = urldecode($file);
- $file = explode(',', $file);
- foreach ($file as $v) {
- $copy = $this->copy($v, $key);
- if (isset($copy['url'])) {
- $result[] = $copy['url'];
- } else {
- $result[] = '';
- }
- }
- return implode(',', $result);
- }
- public function action_api()
- {
- Dever::outDiy($this->output);
- }
- public function start_api()
- {
- Dever::outDiy($this->output);
- }
- public function drag_api()
- {
- if ($this->output['status'] == 1) {
- $this->output['filename'] = $this->output['url'];
- } else {
- $this->output['error'] = $this->output['message'];
- }
-
- Dever::outDiy($this->output);
- }
- public function ueditor_api()
- {
- if ($this->output['status'] == 1) {
- $this->output['state'] = 'SUCCESS';
- $this->output['original'] = 1;
- } else {
- $this->output['url'] = '';
- $this->output['fileType'] = 1;
- $this->output['original'] = 1;
- $this->output['state'] = $this->output['message'];
- }
-
- Dever::outDiy($this->output);
- }
- public function simditor_api()
- {
- if ($this->output['status'] == 1) {
- $this->output['state'] = true;
- $this->output['file_path'] = $this->output['url'];
- } else {
- $this->output['state'] = false;
- }
- Dever::outDiy($this->output);
- }
- public function kindeditor_api()
- {
- if ($this->output['status'] == 1) {
- $this->output['error'] = 0;
- $this->output['url'] = $this->output['url'];
- } else {
- $this->output['error'] = 1;
- $this->output['message'] = $this->output['message'];
- }
-
- Dever::outDiy($this->output);
- }
- }
|