1.5 gin请求上传文件

  • 请求头
  • 请求参数
  • Cookies
  • 上传文件
router.POST("/upload", func(c *gin.Context) {    file, header , err := c.Request.FormFile("upload")    filename := header.Filename    fmt.Println(header.Filename)    out, err := os.Create("./tmp/"+filename+".png")    if err != nil {        log.Fatal(err)    }    defer out.Close()    _, err = io.Copy(out, file)    if err != nil {        log.Fatal(err)    }   })

Leave a Reply

Your email address will not be published. Required fields are marked *