This commit is contained in:
Joren 2024-09-14 03:39:15 +02:00
parent 551e53ad63
commit f6a447d7f4
Signed by: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -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