When I receive a post request with a list of files to be uploaded to the server, I can get a specific file, if I know the name of it via
c.FormFile("filename")
But how would I iterate over the files in that list, without knowing the files names ahead of time? I don't see a method listed in the context docs that simply provides a list of files.
Call c.MultiPartForm() to get a *multipart.Form. Iterate through the form's File field.
form, err := ctx.MultipartForm()
if err != nil { /* handle error */ }
for formFieldName, fileHeaders := range form.File {
    for _, fileHeader := range fileHeaders {
        // process uploaded file here
    }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With