diff --git a/main.go b/main.go index c22c935..4714d62 100644 --- a/main.go +++ b/main.go @@ -2,16 +2,20 @@ package main import ( "fmt" - + "html/template" "os" "path/filepath" + "strings" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() - + // 注册模板函数 + r.SetFuncMap(template.FuncMap{ + "hasSuffix": strings.HasSuffix, + }) // 设置上传文件夹 uploadDir := "./uploads" os.MkdirAll(uploadDir, 0755) @@ -87,7 +91,6 @@ func main() { c.FileAttachment(filepath, filename) }) - r.Run("0.0.0.0:8080") fmt.Println("启动") } diff --git a/templates/index.html b/templates/index.html index a6e6db2..89642cd 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,68 +3,183 @@ - 文件上传/下载 + 文件管理器 - +
-

文件上传/下载管理

+

文件上传 / 管理

- +
-
点击或拖拽文件到这里上传(支持多文件)
+
点击或拖拽上传(支持多文件)
- +
0%
-

文件列表

- - - +
+ + + + + + + + + + + + + +