Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to process image upload #548

Closed
bboshiZ opened this issue Mar 1, 2016 · 1 comment
Closed

how to process image upload #548

bboshiZ opened this issue Mar 1, 2016 · 1 comment

Comments

@bboshiZ
Copy link

bboshiZ commented Mar 1, 2016

POST: multipart/form-data

@otraore
Copy link

otraore commented Mar 14, 2016

http://stackoverflow.com/questions/31792640/retrieving-posted-files-using-golang-gin

    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)
        }   
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants