hzd 1 年之前
父节点
当前提交
fad630c9ce
共有 1 个文件被更改,包括 30 次插入9 次删除
  1. 30 9
      application/common/model/Article.php

+ 30 - 9
application/common/model/Article.php

@@ -17,20 +17,41 @@ class Article extends Base
             $this->error = validate($this->validateName)->getError();
             return false;
         }
-        if($data['type']!=2){
+
+        if($data['type'] == 1){ // pdf
             if(empty($data['path'])){
                 $this->error = '文件不能为空';
                 return false;
             }
-            if($data['type']==1){
-                $s = explode('.',$data['path']);
-                $a = $s[count($s)-1];
-                if($a!='pdf'){
-                    $this->error = '只能上传pdf文件';
-                    return false;
-                }
-            }
 
+            $s = explode('.',$data['path']);
+            $a = $s[count($s)-1];
+            if($a!='pdf'){
+                $this->error = '只能上传pdf文件';
+                return false;
+            }
+        }else if($data['type'] == 3){
+            if(empty($data['video'])){
+                $this->error = '文件不能为空';
+                return false;
+            }
+            $s = explode('.',$data['video']);
+            $a = $s[count($s)-1];
+            if($a!='mp4'){
+                $this->error = '只能上传mp4文件';
+                return false;
+            }
+        }else if($data['type'] == 4){
+            if(empty($data['audio'])){
+                $this->error = '文件不能为空';
+                return false;
+            }
+            $s = explode('.',$data['audio']);
+            $a = $s[count($s)-1];
+            if($a!='mp3'){
+                $this->error = '只能上传mp3文件';
+                return false;
+            }
         }
 
         $id = $data['id'];