Create "temp" directory if it does not exist
This commit is contained in:
parent
c9c8a03f8f
commit
196563a951
5
main.go
5
main.go
|
@ -31,6 +31,11 @@ func uploadFile(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("Error happened receiving file: %v\n", err)
|
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)
|
f, err := os.OpenFile("./temp/"+header.Filename, os.O_WRONLY|os.O_CREATE, 0660)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error happened opening file: %v\n", err)
|
log.Printf("Error happened opening file: %v\n", err)
|
||||||
|
|
Loading…
Reference in New Issue