Skip to content

Commit

Permalink
Merge pull request #562 from appleboy/patch-3
Browse files Browse the repository at this point in the history
Add upload file example
  • Loading branch information
javierprovecho committed Mar 14, 2016
2 parents a7d3be5 + d1f7f35 commit 4a6bc4a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,32 @@ func main() {
id: 1234; page: 1; name: manu; message: this_is_great
```

### Another example: upload file

Reference issue [#548](https://github.com/gin-gonic/gin/issues/548)

```go
func main() {
router := gin.Default()
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)
}
})
router.Run(":8080")
}
```
#### Grouping routes
```go
Expand Down

0 comments on commit 4a6bc4a

Please sign in to comment.