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
+21.8k Golang : How to reverse slice or array elements order
+12.7k Golang : Send data to /dev/null a.k.a blackhole with ioutil.Discard
+5k Python : Convert(cast) bytes to string example
+20k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+7.1k Golang : A simple forex opportunities scanner
+14.4k Golang : On enumeration
+18.4k Golang : How to get hour, minute, second from time?
+12.5k Golang : HTTP response JSON encoded data
+13.6k Golang : Qt progress dialog example
+6.9k Nginx : Password protect a directory/folder
+9.6k Golang : Copy map(hash table) example
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example