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

Golang 生成防识别的图片验证码

验证码 captcha 是对抗密码强力破解、垃圾信息的有效方式,一般用于用户注册、登录,当检测到频繁发帖时也会启用验证码。下面介绍用golang 生成防机器识别的图片验证码。...

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

Submit Comment Login
Based on Golang + fastHTTP + sdb | go1.17.1 Processed in 1ms