Merge pull request #125 from Yuanuo/patch-04

修复重命名文件时验证失败的问题
This commit is contained in:
AaronLiu 2019-01-21 10:18:41 +08:00 committed by GitHub
commit c33b6d587f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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": "请不要更改文件扩展名" } }';