在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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 |
请发表评论