File upload form

This one for you tulg.
This commit is contained in:
CronyAkatsuki 2023-12-21 12:08:07 +01:00
parent 66fd12473e
commit 2c1342a20e
2 changed files with 14 additions and 1 deletions

View file

@ -183,5 +183,10 @@ func Upload(c echo.Context) error {
fileUrl := c.Request().Host + "/files/" + file.Filename + "\n"
return c.String(http.StatusOK, fileUrl)
UserAgent := c.Request().UserAgent()
if regexp.MatchString("^curl/.*", UserAgent); err != nil {
return c.String(http.StatusOK, fileUrl)
}
return c.Redirect(http.StatusMovedPermanently, "/files/"+file.Filename)
}