From 196563a95123e64f8a2cb49d158cf10078fef7e5 Mon Sep 17 00:00:00 2001 From: raul Date: Tue, 30 Apr 2024 12:19:23 +0200 Subject: [PATCH] Create "temp" directory if it does not exist --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index beade32..f135922 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,11 @@ func uploadFile(w http.ResponseWriter, r *http.Request) { log.Printf("Error happened receiving file: %v\n", err) } + _, err = os.Stat("./temp/") + if os.IsNotExist(err) { + os.Mkdir("./temp/", 0700) + } + f, err := os.OpenFile("./temp/"+header.Filename, os.O_WRONLY|os.O_CREATE, 0660) if err != nil { log.Printf("Error happened opening file: %v\n", err)