Permalink
Browse files

Merge pull request #125 from Yuanuo/patch-04

修复重命名文件时验证失败的问题
  • Loading branch information...
HFO4 committed Jan 21, 2019
2 parents 68399a5 + 277f882 commit c33b6d587f5467a19d6ae90cb6f470d515ed8d84
Showing with 6 additions and 4 deletions.
  1. +6 −4 application/index/model/FileManage.php
@@ -162,11 +162,14 @@ static function RenameHandler($fname,$new,$uid,$notEcho = false){
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 @@ static function RenameHandler($fname,$new,$uid,$notEcho = false){
die();
}
$originSuffix = explode(".",$fileRecord["orign_name"]);
$newSuffix = explode(".",$new);
if(end($originSuffix) != end($newSuffix)){
if($notEcho){
return '{ "result": { "success": false, "error": "请不要更改文件扩展名" } }';

0 comments on commit c33b6d5

Please sign in to comment.