Golang net/http.Request.ParseMultipartForm() function example
package net/http
Golang net/http.Request.ParseMultipartForm() function usage example
func uploadHandler(w http.ResponseWriter, r *http.Request) {
err := r.ParseMultipartForm(200000) // grab the multipart form
if err != nil {
fmt.Fprintln(w, err)
return
}
formdata := r.MultipartForm // ok, no problem so far, read the Form data
//get the *fileheaders
files := formdata.File["multiplefiles"] // grab the filenames
for i, _ := range files { // loop through the files one by one
file, err := files[i].Open()
defer file.Close()
if err != nil {
fmt.Fprintln(w, err)
return
}
}
...
see full example at : https://www.socketloop.com/tutorials/upload-multiple-files-golang
References :
http://golang.org/pkg/net/http/#Request.ParseMultipartForm
https://www.socketloop.com/tutorials/upload-multiple-files-golang
Advertisement
Something interesting
Tutorials
+9.5k Golang : Accessing content anonymously with Tor
+6.1k Golang : How to write backslash in string?
+12k Golang : Decompress zlib file example
+36.3k Golang : Convert(cast) int64 to string
+6.1k Golang : Get missing location after unmarshal binary and gob decode time.
+5.3k Golang : Generate Interleaved 2 inch by 5 inch barcode
+5.8k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag
+18.4k Golang : How to remove certain lines from a file
+7.1k Golang : Array mapping with Interface
+10.5k Generate Random number with math/rand in Go
+6.3k Golang : Test input string for unicode example
+4.7k Linux/MacOSX : How to symlink a file?