Problems parsing HTTP POST multipart/form-data

Hello, this is my first post here on this forum.
I have a problem in parsing multipart/form-data.
Here is what I did:

func handleIncomingUploads(w http.ResponseWriter, r *http.Request){

	log.Printf("%#v", r.Header.Get("Content-Type"))


	file, handler, err:=r.FormFile("file")
	if err!=nil{
		log.Println("Error retrieving the file:", err)
	defer file.Close()

	log.Printf("Uploaded File: %+v\n", handler.Filename)
	log.Printf("File Size: %+v\n", handler.Size)
	log.Printf("MIME Header: %+v\n", handler.Header)

	fileBytes, err := ioutil.ReadAll(file)
	if err != nil {


	err=ioutil.WriteFile(filepath, fileBytes, 0777)
	if err != nil {

	log.Println("File successfully uploaded.")

What I’m doing here is trying to parse a form having three fields: username, imei and file.
The last one contains a file (obviously) and it is well parsed and saved by this code.
Now the problem is on the other two, they are two string values, but they are not correctly parsed, i have an empty string.

I made some attempts using Postman and I noticed that those two fields are correctly parsed only if I choose x-www-form-urlencoded instead of form-data.
So I can’t understand what’s wrong here. Can someone help me please?

Thanks in advance.

Yesterday I finally figured out where the problem was (and it makes me feel like an idiot).
The problem is in ParseMultipartForm(math.MaxInt64), in particular in the parameter passed to the function. Reading the docs I saw what is the purpose of this parameter, that is to tell how much memory must be allocated in RAM to parse the data contained in the form. Now, MaxInt64 is just a little bigger than the memory available on my machine… 8589934591 GB.

So the solution to my problem was to set a correct value of memory to allocate for parsing.