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.4k Golang : Web(Javascript) to server-side websocket example
+11.6k Android Studio : Create custom icons for your application example
+51.1k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+7k Web : How to see your website from different countries?
+8.6k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+24.5k Golang : Time slice or date sort and reverse sort example
+12k Golang : Decompress zlib file example
+25.9k Golang : How to read integer value from standard input ?
+5.7k Linux/Unix/PHP : Restart PHP-FPM
+15.2k JavaScript/JQuery : Detect or intercept enter key pressed example
+8.6k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+9.4k Golang : Play .WAV file from command line