FormFile

MultipartForm files can be retrieved by name, the first file from the given key is returned.

  1. c.FormFile(name string) (*multipart.FileHeader, error)
  1. app.Post("/", func(c *fiber.Ctx) {
  2. // Get first file from form field "document":
  3. file, err := c.FormFile("document")
  4.  
  5. // Check for errors:
  6. if err == nil {
  7. // Save file to root directory:
  8. c.SaveFile(file, fmt.Sprintf("./%s", file.Filename))
  9. }
  10. })