dever vor 6 Jahren
Ursprung
Commit
8395c062a4
1 geänderte Dateien mit 17 neuen und 5 gelöschten Zeilen
  1. 17 5
      src/Save.php

+ 17 - 5
src/Save.php

@@ -13,8 +13,13 @@ class Save
 {
 	public function __construct()
 	{
-		$image['file'] 	= Dever::input('file');
-		$image['key'] 	= Dever::input('key');
+		
+	}
+
+	private function upload($file = false, $key = 1)
+	{
+		$image['file'] 	= Dever::input('file', $file);
+		$image['key'] 	= Dever::input('key', $key);
 		
 		//file_put_contents(DEVER_PATH . 'web/data/upload.txt', var_export($image, true)); 
 		if ($image['file']) {
@@ -25,9 +30,10 @@ class Save
 		}
 	}
 
-	public function copy($file = false, $key = 1)
+	public function copy($file = false, $key = 1, $state = false)
 	{
-		if ($this->output) {
+		if (Dever::input('file') && $state == false) {
+			$this->upload();
 			Dever::outDiy($this->output);
 		} else {
 			$image['file'] 	= $file;
@@ -45,7 +51,7 @@ class Save
 		$file = urldecode($file);
 		$file = explode(',', $file);
 		foreach ($file as $v) {
-			$copy = $this->copy($v, $key);
+			$copy = $this->copy($v, $key, true);
 			if (isset($copy['url'])) {
 				$result[] = $copy['url'];
 			} else {
@@ -58,16 +64,19 @@ class Save
 
 	public function action_api()
 	{
+		$this->upload();
 		Dever::outDiy($this->output);
 	}
 
 	public function start_api()
 	{
+		$this->upload();
 		Dever::outDiy($this->output);
 	}
 
 	public function drag_api()
 	{
+		$this->upload();
 		if ($this->output['status'] == 1) {
 			$this->output['filename'] = $this->output['url'];
 		} else {
@@ -79,6 +88,7 @@ class Save
 
 	public function ueditor_api()
 	{
+		$this->upload();
 		if ($this->output['status'] == 1) {
 			$this->output['state'] = 'SUCCESS';
 			$this->output['original'] = 1;
@@ -94,6 +104,7 @@ class Save
 
 	public function simditor_api()
 	{
+		$this->upload();
 		if ($this->output['status'] == 1) {
 			$this->output['state'] = true;
 			$this->output['file_path'] = $this->output['url'];
@@ -106,6 +117,7 @@ class Save
 
 	public function kindeditor_api()
 	{
+		$this->upload();
 		if ($this->output['status'] == 1) {
 			$this->output['error'] = 0;
 			$this->output['url'] = $this->output['url'];