package main
import (
"fmt"
"github.com/gin-gonic/gin"
"log"
"net/http"
)
func main() {
router := gin.Default()
// 为 multipart forms 设置较低的内存限制 (默认是 32 MiB)
// router.MaxMultipartMemory = 8 << 20 // 8 MiB
router.POST("/upload", shuanchuan)
router.Run(":8080")
}
func shuanchuan(c *gin.Context) {
// 单文件
file, _ := c.FormFile("file")
log.Println(file.Filename)
//上传文件至指定目录
dst := "pdf"
c.SaveUploadedFile(file, dst)
c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename))
}