From f6a447d7f41b2b9a4627e352b30e9d4662887ffc Mon Sep 17 00:00:00 2001 From: Joren Date: Sat, 14 Sep 2024 03:39:15 +0200 Subject: [PATCH] Hm --- handlers.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/handlers.go b/handlers.go index 6fcd0c8..642533d 100644 --- a/handlers.go +++ b/handlers.go @@ -74,22 +74,22 @@ func handleUpload(w http.ResponseWriter, r *http.Request) { } defer file.Close() - dst, err := os.Create(filepath.Join(uploadDir, fileHeader.Filename)) + tempFile, err := os.CreateTemp(uploadDir, fileHeader.Filename) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - defer dst.Close() + defer tempFile.Close() - _, err = io.Copy(dst, file) + _, err = io.Copy(tempFile, file) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - uploadedFiles = append(uploadedFiles, fileHeader.Filename) + uploadedFiles = append(uploadedFiles, filepath.Base(tempFile.Name())) - _, err = parseInputFile(dst.Name()) + _, err = parseInputFile(tempFile.Name()) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return