dever 7 år sedan
förälder
incheckning
2cf19bdf2d
3 ändrade filer med 18 tillägg och 5 borttagningar
  1. 2 2
      database/upload.php
  2. 12 0
      src/Save.php
  3. 4 3
      src/Store/Core.php

+ 2 - 2
database/upload.php

@@ -141,13 +141,13 @@ return array
 	# 默认值
 	'default' => array
 	(
-		'col' => 'name,cover,type,alter,state,cdate',
+		'col' => 'name,cover,type,state,cdate',
 		'value' => array
 		(
 			'"默认图片配置",1,"jpg,png,gif",1,' . time(),
 			'"默认音频配置",1,"mp3",1,' . time(),
 			'"默认视频配置",1,"mp4",1,' . time(),
-			'"默认文件配置",1,"jpg,png,gif,doc,pdf,rar,zip,xls,xlsx,docx","t=1",1,' . time(),
+			'"默认文件配置",1,"jpg,png,gif,doc,pdf,rar,zip,xls,xlsx,docx",1,' . time(),
 		),
 	),
 	

+ 12 - 0
src/Save.php

@@ -17,11 +17,23 @@ class Save
 		$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 action_api()

+ 4 - 3
src/Store/Core.php

@@ -177,24 +177,25 @@ class Core
 		$this->output['status'] = 1; 
 
 		if (is_string($this->data['file'])) {
+			/*
 			if (strpos($this->data['file'], 'http') !== false) {
 				$this->output['status'] = -1;
 				$this->output['message'] = '暂时不支持复制网络文件';
-
 				return $this->output;
 			}
-
+			*/
 			$this->root();
 
 			header('Content-type: text/json; charset=utf-8');
 
-			$file = base64_decode($this->data['file']);
+			$file = file_get_contents($this->data['file']);
 			$path = Dever::path($this->base, 'tmp/');
 			$this->data['file'] = array();
 			$this->data['file']['name'] = 'Tmp' . Helper::rand(8) . md5(microtime() . rand(0,1000)) . '.jpg';
 			$this->data['file']['tmp_name'] = $path . $this->data['file']['name'];
 			file_put_contents($this->data['file']['tmp_name'], $file);
 			$this->data['file']['size'] = filesize($this->data['file']['tmp_name']);
+			
 		} else {
 			header("Content-type: application/json; charset=utf-8");
 		}