GolangNote

Golang笔记

golang 获取上传文件文件名

Permalink

golang 获取上传文件文件名

golang 获取上传文件文件名

Go: uploadHandler
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")
 }

Related articles

Write a Comment to "golang 获取上传文件文件名"

Submit Comment Login
Based on Golang + fastHTTP + youdb | go1.16 Processed in 1ms