From 8113202f5f762bd29f889c4b5d208cd772ba3155 Mon Sep 17 00:00:00 2001 From: CronyAkatsuki Date: Tue, 19 Dec 2023 21:49:49 +0100 Subject: [PATCH] Check if a file with same name already exist's --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index 7a408f9..5fe6313 100644 --- a/main.go +++ b/main.go @@ -67,6 +67,10 @@ func Upload(c echo.Context) error { return err } + if _, err := os.Stat("files/" + file.Filename); err == nil { + return c.String(http.StatusOK, "A file with the same name already exist's on the server.\n") + } + src, err := file.Open() if err != nil { return err