Hm
This commit is contained in:
parent
551e53ad63
commit
f6a447d7f4
10
handlers.go
10
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
|
||||
|
Loading…
Reference in New Issue
Block a user