du_1993
2014-08-10 05:11
浏览 43
已采纳

将图像从html表单传递到Go

I have a html page that has the follow code.

<form action="/image" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

I then have some Go code to get the file on the back end.

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

   userInput := r.FormValue("file")

but anytime I try to use userInput from the go script, it returns nothing. Am I passing the variables wrong?

EDIT: I know how to upload things to golang that are text/passwords. I am having trouble uploading images to Go with the code.

EDIT 2: Read the Go guide a found the solution. See below.

1条回答 默认 最新

相关推荐 更多相似问题