标签:web nbsp max ase oct log max size turn osi
for i := 1; i <= 9; i++ { name := fmt.Sprintf("image%d", i) file, header, err := r.FormFile(name) if err != nil { logs.DebugPrint(err.Error()) break } logs.DebugPrint(header.Filename, header.Header, header.Size) if header.Size > mewNet.MaxImageSize { code, msg, debugMsg = j.CodeContentTooLong, j.MsgContentTooLong, fmt.Sprintf("max size:%v b upload size:%v b", header.Size, mewNet.MaxImageSize) } index := strings.LastIndex(header.Filename, ".") if index < 0 { code, msg, debugMsg = j.CodeSaveImageError, j.MsgSaveImageError, "not image type" return } subfix := header.Filename[index:] switch subfix { case ".jpg", ".jpeg", ".png", ".ico", ".gif", ".wbmp", ".bmp", ".svg", ".webp": default: code, msg, debugMsg = j.CodeSaveImageError, j.MsgSaveImageError, "not image type" return } imgType = append(imgType, subfix) fileNames = append(fileNames, name) files = append(files, file) }
下面是 logs.DebugPrint(header.Filename, header.Header, header.Size) 的输出,包含了文件名,文件的http Header,文件大小
default1.jpg map[Content-Disposition:[form-data; name="image1"; filename="default1.jpg"] Content-Type:[application/octet-stream]] 45814
go multipart/form-data 文件大小,文件信息,处理后缀
标签:web nbsp max ase oct log max size turn osi
原文地址:http://www.cnblogs.com/cdyboke/p/7345066.html