Kaynağa Gözat

修复文件上传错误

Minho 8 yıl önce
ebeveyn
işleme
ff9f2a07b1
2 değiştirilmiş dosya ile 3 ekleme ve 0 silme
  1. 1 0
      commands/command.go
  2. 2 0
      graphics/file.go

+ 1 - 0
commands/command.go

@@ -57,6 +57,7 @@ func RegisterDataBase() {
 		if strings.HasPrefix(database,"./") {
 			database = filepath.Join(WorkingDirectory,string(database[1:]))
 		}
+
 		dbPath := filepath.Dir(database)
 		os.MkdirAll(dbPath, 0777)
 

+ 2 - 0
graphics/file.go

@@ -13,6 +13,8 @@ import (
 // 将图片保存到指定的路径
 func SaveImage(p string, src image.Image) error {
 
+	os.MkdirAll(filepath.Dir(p),0666)
+
 	f, err := os.OpenFile(p, os.O_SYNC|os.O_RDWR|os.O_CREATE, 0666)
 
 	if err != nil {