Use proper filepaths

This commit is contained in:
2025-01-19 09:31:19 +01:00
parent 62e75eaea8
commit b8fd81a86d
8 changed files with 45 additions and 38 deletions

View File

@@ -5,6 +5,7 @@ import (
"html/template"
"log"
"net/http"
"path/filepath"
b "streifling.com/jason/cpolis/cmd/backend"
)
@@ -70,7 +71,7 @@ func UploadImage(c *b.Config, s map[string]*Session, fileKey, htmlFile, htmlTemp
data := new(struct{ Image string })
data.Image = filename
tmpl, err := template.ParseFiles(c.WebDir + "/templates/" + htmlFile)
tmpl, err := template.ParseFiles(filepath.Join(c.WebDir, "templates", htmlFile))
if err = template.Must(tmpl, err).ExecuteTemplate(w, htmlTemplate, data); err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)