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
+11.6k Get form post value in Go
+10.2k Golang : Check a web page existence with HEAD request example
+17.6k Golang : delete and modify XML file content
+18.6k Golang : Find IP address from string
+7.8k Swift : Convert (cast) String to Double
+5k Golang : Constant and variable names in native language
+4.5k Java : Generate multiplication table example
+12.3k Golang : Get month name from date example
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+5.5k Golang : Stop goroutine without channel
+5.8k Javascript : How to replace HTML inside <div>?