dever 7 年之前
父節點
當前提交
23b225d378
共有 2 個文件被更改,包括 28 次插入8 次删除
  1. 16 0
      src/Save.php
  2. 12 8
      src/Store/Core.php

+ 16 - 0
src/Save.php

@@ -36,6 +36,22 @@ class Save
 		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);

+ 12 - 8
src/Store/Core.php

@@ -23,7 +23,7 @@ class Core
 
 	protected $path;
 
-	protected $ext;
+	protected $ext = '';
 
 	protected $file;
 
@@ -130,13 +130,14 @@ class Core
 	 */
 	private function check_type()
 	{
-		$ext = $this->getExt($this->data['file']['tmp_name']);
-		if (strpos($this->config['type'], $ext) === false) {
-			$this->output['status'] = -1;
-			$this->output['message'] = '文件格式不符合要求';
+		if (!$this->ext) {
+			$ext = $this->getExt($this->data['file']['tmp_name']);
+			if (strpos($this->config['type'], $ext) === false) {
+				$this->output['status'] = -1;
+				$this->output['message'] = '文件格式不符合要求';
+			}
+			$this->ext = '.' . $ext;
 		}
-
-		$this->ext = '.' . $ext;
 	}
 	
 	/**
@@ -197,6 +198,9 @@ class Core
 
 			if (!is_file($this->data['file']['tmp_name'])) {
 				$file = Dever::curl($name);
+				if (stristr($file, 'webp')) {
+					$this->ext = '.jpg';
+				}
 				file_put_contents($this->data['file']['tmp_name'], $file);
 			}
 			$this->data['file']['size'] = filesize($this->data['file']['tmp_name']);
@@ -470,7 +474,7 @@ class Core
 	}
 	
 	/**
-	 * getExt 已废弃
+	 * getExt
 	 * 
 	 * @return mixed
 	 */