fix: CopyUploadFile文件复制判断非目录

This commit is contained in:
TsMask
2024-04-16 19:41:19 +08:00
parent 07f6b9c31a
commit 438ba4a06b

View File

@@ -317,7 +317,7 @@ func CopyUploadFile(filePath, dst string) error {
}
// 如果目标文件已经存在,先将目标文件重命名
if _, err := os.Stat(dst); err == nil {
if info, err := os.Stat(dst); err == nil && !info.IsDir() {
ext := filepath.Ext(dst)
name := dst[0 : len(dst)-len(ext)]
newName := fmt.Sprintf("%s-%s%s", name, time.Now().Format("20060102_150405"), ext)