dever vor 6 Jahren
Ursprung
Commit
eb6c303fce
3 geänderte Dateien mit 23 neuen und 8 gelöschten Zeilen
  1. 2 4
      src/Save.php
  2. 13 2
      src/Store/Core.php
  3. 8 2
      src/View.php

+ 2 - 4
src/Save.php

@@ -92,12 +92,11 @@ class Save
 	{
 		if ($this->output['status'] == 1) {
 			$this->output['state'] = true;
+			$this->output['file_path'] = $this->output['url'];
 		} else {
 			$this->output['state'] = false;
 		}
 
-		$this->output['file_path'] = $this->output['url'];
-		
 		Dever::outDiy($this->output);
 	}
 
@@ -105,12 +104,11 @@ class Save
 	{
 		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'];
 		}
-
-		$this->output['url'] = $this->output['url'];
 		
 		Dever::outDiy($this->output);
 	}

+ 13 - 2
src/Store/Core.php

@@ -301,13 +301,22 @@ class Core
 		if (!function_exists('finfo_open')) {
 			return $this->getExtByByte($filename);
 		}
+
+		if (isset($this->data['file']['type'])) {
+			$ext = $this->getExtByMine($this->data['file']['type']);
+		}
 		$finfo = finfo_open(FILEINFO_MIME); // 返回 mime 类型
 		$code = finfo_file($finfo, $filename);
 		finfo_close($finfo);
 		$temp = explode(';', $code);
 		$ext = $this->getExtByMine($temp[0]);
-		if (!$ext || $ext == 'txt') {
-			$ext = $this->getExtByByte($filename);
+		if (!$ext || $ext == 'txt' || $ext == 'exe') {
+			if (isset($this->data['file']['type'])) {
+				$ext = $this->getExtByMine($this->data['file']['type']);
+			}
+			if (!$ext || $ext == 'txt' || $ext == 'exe') {
+				$ext = $this->getExtByByte($filename);
+			}
 		}
 
 		return $ext;
@@ -333,6 +342,7 @@ class Core
 			'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx',
 			'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx',
 			'video/x-m4v' => 'mp4',
+			'video/mp4' => 'mp4',
 			'application/octet-stream' => 'exe',
 			'application/oda' => 'oda',
 			'application/olescript' => 'axs',
@@ -417,6 +427,7 @@ class Core
 			'audio/mid' => 'mid',
 			'audio/mid' => 'rmi',
 			'audio/mpeg' => 'mp3',
+			'audio/mp3' => 'mp3',
 			'audio/x-aiff' => 'aif',
 			'audio/x-aiff' => 'aifc',
 			'audio/x-aiff' => 'aiff',

+ 8 - 2
src/View.php

@@ -50,10 +50,16 @@ class View
         $data['total'] = Dever::total();
         
         if ($data['file']) {
+            $pic = Dever::config('host')->script . 'img/video.jpg';
             foreach ($data['file'] as $k => $v) {
                 $data['file'][$k]['url'] = Dever::upload('{uploadRes}' . $v['file']);
-                if (!isset($v['pic'])) {
-                    $data['file'][$k]['pic'] = Dever::upload('{uploadRes}' . $v['file']);
+                if ($v['ext'] != '.jpg' && $v['ext'] != '.png' && $v['ext'] != '.bmp') {
+                    $data['file'][$k]['pic'] = $pic;
+                } else {
+                    $data['file'][$k]['pic'] = $data['file'][$k]['url'];
+                }
+                if (!isset($data['file'][$k]['pic'])) {
+                    $data['file'][$k]['pic'] = $pic;
                 }
             }
         }