GolangNote

Golang笔记

golang 获取上传文件文件名

Permalink

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")
 }

本文网址: https://golangnote.com/topic/135.html 转摘请注明来源

Related articles

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

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.22.3 Processed in 2ms