From de4b2c42c4ff91ba720b7fb783234b66d3d38f04 Mon Sep 17 00:00:00 2001 From: neo1989 Date: Tue, 9 Apr 2019 18:24:42 +0800 Subject: [PATCH] 'file' is THE filedname sometime --- gorequest.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gorequest.go b/gorequest.go index 6ef0093..ac1160d 100644 --- a/gorequest.go +++ b/gorequest.go @@ -877,7 +877,7 @@ type File struct { // End() // // The second optional argument (third argument overall) is the fieldname in the multipart/form-data request. It defaults to fileNUMBER (eg. file1), where number is ascending and starts counting at 1. -// So if you send multiple files, the fieldnames will be file1, file2, ... unless it is overwritten. If fieldname is set to "file" it will be automatically set to fileNUMBER, where number is the greatest exsiting number+1. +// So if you send multiple files, the fieldnames will be file1, file2, ... unless it is overwritten. If fieldname is set to "" it will be automatically set to fileNUMBER, where number is the greatest exsiting number+1. // // b, _ := ioutil.ReadFile("./example_file.ext") // gorequest.New(). @@ -897,7 +897,7 @@ func (s *SuperAgent) SendFile(file interface{}, args ...string) *SuperAgent { if len(args) >= 2 && len(args[1]) > 0 { fieldname = strings.TrimSpace(args[1]) } - if fieldname == "file" || fieldname == "" { + if fieldname == "" { fieldname = "file" + strconv.Itoa(len(s.FileData)+1) }