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
+12.8k Golang : http.Get example
+8.3k Golang: Prevent over writing file with md5 hash
+11.9k Golang : Convert(cast) bigint to string
+4.8k PHP : Extract part of a string starting from the middle
+14k Golang : Compress and decompress file with compress/flate example
+9.3k Golang : Temperatures conversion example
+30k Golang : Get time.Duration in year, month, week or day
+7k Golang : Takes a plural word and makes it singular
+8.1k Golang : Tell color name with OpenCV example
+6.7k Golang : Humanize and Titleize functions
+5.4k Golang : Return multiple values from function
+16.4k Golang : Send email and SMTP configuration example