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

File upload not working #80

Open
jonathanwilke opened this issue Aug 7, 2017 · 1 comment
Open

File upload not working #80

jonathanwilke opened this issue Aug 7, 2017 · 1 comment

Comments

@jonathanwilke
Copy link

jonathanwilke commented Aug 7, 2017

Hi,

when I try to upload a file via a multipart/form-data request I get the error multipart: NextPart: EOF

My code looks like this:

func (c *TypeContext) UserUploadProfilePicture(rw web.ResponseWriter, req *web.Request) {
  var (
    err error
    file multipart.File
    handler *multipart.FileHeader
  )

  req.ParseMultipartForm(32 << 20)
  file, handler, err = req.FormFile("profile_picture")

  if err != nil {
    return
  }

  defer file.Close()

  f, err := os.OpenFile("./test/"+handler.Filename, os.O_WRONLY|os.O_CREATE, 0666)

  if err != nil {
    return
  }
  defer f.Close()

  io.Copy(f, file)
}
@annaelizabeth2019
Copy link

Was this ever resolved? I'm having the same problem.

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