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