|
@@ -13,6 +13,7 @@ class Attachment
|
|
|
// 单个图片上传
|
|
|
public function tplFieldImage()
|
|
|
{
|
|
|
+ $this->validateExt(['jpg,png,jpeg']);
|
|
|
$file = request()->file("file");
|
|
|
$savename = \think\facade\Filesystem::disk('public')->putFile('images',$file);
|
|
|
if($file){
|
|
@@ -39,6 +40,7 @@ class Attachment
|
|
|
// 视频文件上传
|
|
|
public function tplFieldVideo()
|
|
|
{
|
|
|
+ $this->validateExt(['mp4,avi,wmv,mpg,mpeg']);
|
|
|
$file = request()->file("file");
|
|
|
$savename = \think\facade\Filesystem::disk('public')->putFile('videos',$file);
|
|
|
if($file){
|
|
@@ -58,5 +60,12 @@ class Attachment
|
|
|
page_result(1, "上传失败,请稍后重试");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ public function validateExt($ext_arr)
|
|
|
+ {
|
|
|
+ $ext = pathinfo($_FILES['file']['name'])['extension'];
|
|
|
+ if (!in_array($ext,$ext_arr)) {
|
|
|
+ page_result(1, "文件格式不正确");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|