diff --git a/main.go b/main.go index dde5e7e..2c7cabd 100644 --- a/main.go +++ b/main.go @@ -29,10 +29,6 @@ func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Con } func upload(c echo.Context) error { - //----------- - // Read file - //----------- - // Source file, err := c.FormFile("file") if err != nil { @@ -95,6 +91,12 @@ func index(c echo.Context) error { return c.Render(http.StatusOK, "index", map[string][]File{"Files": files}) } +func remove(c echo.Context) error { + filename := c.FormValue("Filename") + os.Remove(filepath.Join(DATA_DIR, filename)) + return c.Redirect(http.StatusTemporaryRedirect, "/admin") +} + func main() { t := &Template{ templates: template.Must(template.ParseGlob("views/templates/*.html")), @@ -110,6 +112,7 @@ func main() { e.Static("/assets", "assets") e.GET("/admin", index) e.POST("/admin/upload", upload) + e.GET("/admin/remove", remove) e.Logger.Fatal(e.Start(":1323")) } diff --git a/views/templates/index.html b/views/templates/index.html index fb01471..17279c9 100644 --- a/views/templates/index.html +++ b/views/templates/index.html @@ -11,7 +11,7 @@
Enfin une solution simple que vous gérez vous même
@@ -31,7 +31,7 @@