Golang mime/multipart.FileHeader.Open() function example
package mime/multipart
Golang mime/multipart.FileHeader.Open() function usage example
formdata := r.MultipartForm // ok, no problem so far, read the Form data
//get the *fileheaders
fileHeaders := formdata.File["multiplefiles"] // grab the filenames
for i, _ := range fileHeaders { // loop through the files one by one
file, err := fileHeaders[i].Open() // <--------------------- here!
defer file.Close()
if err != nil {
fmt.Fprintln(w, err)
return
}
w.Write([]byte(fmt.Sprintf("Filename : %s open successfully.", fileHeaders[i].Filename)))
}
References :
https://www.socketloop.com/tutorials/upload-multiple-files-golang
Advertisement
Something interesting
Tutorials
+7.6k Golang : Handling Yes No Quit query input
+8.3k Golang : Routes multiplexer routing example with regular expression control
+11.2k How to test Facebook App on localhost ?
+27.6k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+17.2k Golang : Get number of CPU cores
+39.2k Golang : How to iterate over a []string(array)
+16.5k Golang : Loop each day of the current month example
+14.5k Golang : Parsing or breaking down URL
+10.4k Golang : How to profile or log time spend on execution?
+22.5k Golang : Read directory content with filepath.Walk()
+26k Golang : Daemonizing a simple web server process example
+25.6k Golang : Convert long hexadecimal with strconv.ParseUint example