diff --git a/cmd/view/articles.go b/cmd/view/articles.go index 5bd0ac2..14b18e7 100644 --- a/cmd/view/articles.go +++ b/cmd/view/articles.go @@ -413,8 +413,9 @@ func UploadImage(c *control.CliArgs) http.HandlerFunc { } defer file.Close() - filename := fmt.Sprint(c.PicsDir, "/", time.Now().Format("2006-01-02_15:04:05"), "-", header.Filename) - absFilepath, err := filepath.Abs(filename) + filename := fmt.Sprint(time.Now().Format("2006-01-02_15:04:05"), "-", + header.Filename) + absFilepath, err := filepath.Abs(fmt.Sprint(c.PicsDir, "/", filename)) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) @@ -435,8 +436,8 @@ func UploadImage(c *control.CliArgs) http.HandlerFunc { return } + imgMD := fmt.Sprint("![", header.Filename, "](/pics/", filename, ")") tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html") - tmpl = template.Must(tmpl, err) - tmpl.ExecuteTemplate(w, "editor-images", fmt.Sprint("![", header.Filename, "](", filename, ")")) + template.Must(tmpl, err).ExecuteTemplate(w, "editor-images", imgMD) } }