|
@@ -69,10 +69,18 @@ func UploadFile(code, fileName, url string, bt []byte) (string, string, string,
|
|
|
} else {
|
|
|
newFileType = util.GetFileType(bt)
|
|
|
}
|
|
|
- //newFileType字节解析出来的文件类型不是常见类型时,替换成oldFileType
|
|
|
- if newFileType != oldFileType && !commUsedReg.MatchString(newFileType) && oldFileType != "" {
|
|
|
- newFileType = oldFileType
|
|
|
+ if !commUsedReg.MatchString(newFileType) {
|
|
|
+ if !commUsedReg.MatchString(oldFileType) { //都不是常见的附件不上传
|
|
|
+ logger.Error("上传文件出错,该文件类型禁止上传!", code, " upload file "+fileName, url)
|
|
|
+ return "", fileName, size, newFileType, ""
|
|
|
+ } else if newFileType != oldFileType && oldFileType != "" {
|
|
|
+ newFileType = oldFileType
|
|
|
+ }
|
|
|
}
|
|
|
+ //newFileType字节解析出来的文件类型不是常见类型时,替换成oldFileType
|
|
|
+ // if newFileType != oldFileType && !commUsedReg.MatchString(newFileType) && oldFileType != "" {
|
|
|
+ // newFileType = oldFileType
|
|
|
+ // }
|
|
|
//禁止上传
|
|
|
if filterTypeReg.MatchString(newFileType) {
|
|
|
if oldFileType != "doc" && oldFileType != "docx" {
|