Create "temp" directory if it does not exist

This commit is contained in:
raul 2024-04-30 12:19:23 +02:00
parent c9c8a03f8f
commit 196563a951
1 changed files with 5 additions and 0 deletions

View File

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