From 277f882e8d3b4c3e301566d4795f8dd70dd9561b Mon Sep 17 00:00:00 2001 From: Yuanuo Date: Thu, 17 Jan 2019 14:05:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=E9=AA=8C=E8=AF=81=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20=E6=96=87=E4=BB=B6=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E6=97=B6=EF=BC=8C=E6=96=87=E4=BB=B6=E5=90=8E?= =?UTF-8?q?=E7=BC=80=E5=90=8D=E4=B9=8B=E5=89=8D=E7=9A=84=E2=80=98.?= =?UTF-8?q?=E2=80=99=E4=BC=9A=E5=AF=BC=E8=87=B4=E9=AA=8C=E8=AF=81=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=EF=BC=8C=E5=90=8E=E5=8F=B0=E5=81=9A=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E6=97=B6=E5=BA=94=E8=AF=A5=E5=85=88=E5=8E=BB=E9=99=A4=E5=90=8E?= =?UTF-8?q?=E7=BC=80=E5=90=8D=E9=83=A8=E5=88=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/model/FileManage.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/application/index/model/FileManage.php b/application/index/model/FileManage.php index 9fc19e45..45c5ff51 100644 --- a/application/index/model/FileManage.php +++ b/application/index/model/FileManage.php @@ -162,11 +162,14 @@ class FileManage extends Model{ if(!$notEcho){ $new = str_replace(" ", "", $new); } - if(!self::fileNameValidate($new)){ + $newSuffix = explode(".",$new); + // 文件名带有‘.’会导致验证失败 + $newPrefix = str_replace($newSuffix, "", $new); + if(!self::fileNameValidate($newPrefix)){ if($notEcho){ - return '{ "result": { "success": false, "error": "文件名只支持数字、字母、下划线" } }'; + return '{ "result": { "success": false, "error": "文件名只支持汉字、字母、数字和下划线_及破折号-" } }'; } - die('{ "result": { "success": false, "error": "文件名只支持数字、字母、下划线" } }'); + die('{ "result": { "success": false, "error": "文件名只支持汉字、字母、数字和下划线_及破折号-" } }'); } $path = self::getFileName($fname)[1]; $fname = self::getFileName($fname)[0]; @@ -182,7 +185,6 @@ class FileManage extends Model{ die(); } $originSuffix = explode(".",$fileRecord["orign_name"]); - $newSuffix = explode(".",$new); if(end($originSuffix) != end($newSuffix)){ if($notEcho){ return '{ "result": { "success": false, "error": "请不要更改文件扩展名" } }';