FormFile
MultipartForm files can be retrieved by name, the first file from the given key is returned.
- c.FormFile(name string) (*multipart.FileHeader, error)
- app.Post("/", func(c *fiber.Ctx) {
- // Get first file from form field "document":
- file, err := c.FormFile("document")
- // Check for errors:
- if err == nil {
- // Save file to root directory:
- c.SaveFile(file, fmt.Sprintf("./%s", file.Filename))
- }
- })