Skip to content
Myr

Merge pull request #562 from appleboy/patch-3

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add upload file example

authored by Javier Provecho Fernandez · committed by Javier Provecho Fernandez · parents a7d3be5, d1f7f35 · Browse files · 1 file+26 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+26 added−0 removed

  • other:+26 added−0 removed

1 file+26 added−0 removed

modified:README.md+26 added
216 unmodified lines
217```218id: 1234; page: 1; name: manu; message: this_is_great219```220221### Another example: upload file222223Reference issue [#548](https://github.com/gin-gonic/gin/issues/548)224225```go226func main() {227 router := gin.Default()228229 router.POST("/upload", func(c *gin.Context) {230231 file, header , err := c.Request.FormFile("upload")232 filename := header.Filename233 fmt.Println(header.Filename)234 out, err := os.Create("./tmp/"+filename+".png")235 if err != nil {236 log.Fatal(err)237 }238 defer out.Close()239 _, err = io.Copy(out, file)240 if err != nil {241 log.Fatal(err)242 } 243 })244 router.Run(":8080")245}246```247248#### Grouping routes249```go250func main() {251 router := gin.Default()
462 unmodified lines