github.com/gogf/gf@v1.16.9/.example/net/ghttp/client/upload-batch/client2.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/gogf/gf/net/ghttp"
     6  	"github.com/gogf/gf/os/glog"
     7  )
     8  
     9  func main() {
    10  	path1 := "/Users/john/Pictures/logo1.png"
    11  	path2 := "/Users/john/Pictures/logo2.png"
    12  	r, e := ghttp.Post(
    13  		"http://127.0.0.1:8199/upload",
    14  		fmt.Sprintf(`upload-file[]=@file:%s&upload-file[]=@file:%s`, path1, path2),
    15  	)
    16  	if e != nil {
    17  		glog.Error(e)
    18  	} else {
    19  		fmt.Println(string(r.ReadAll()))
    20  		r.Close()
    21  	}
    22  }