golang 获取上传文件文件名
1 2 3 4 5 6 7 8 9 10 11 12 13 14
func uploadHandler(w http.ResponseWriter, r *http.Request) {
r.ParseMultipartForm(32 << 20)
file, handler, err := r.FormFile("uploadfile")
defer file.Close()
if err != nil {
fmt.Fprintln(w, err)
return
}
// fmt.Println(handler.Header)
filename := handler.Filename // get the filename
fmt.Fprintf(w,"Filename is" + filename + "\n")
}
本文网址: https://golangnote.com/topic/135.html 转摘请注明来源