How can I display uploaded image on text/template?

Hello, everybody.
The image upload handle is correct.
but I can’t display images.
Is it similar to?

For example Pimage has next value.
.Pimage = “./template-images/p1.jpg”
And the image exist in template-images directory.
-project
-template-images
-p1.jpg
-main.go
and It doesn’t show the image.

what issue?

You need to show how you serve static files and how your template looks like.

But basically you just need to create a IMG tag with a src attribute pointing to the URL on your server that maps to the static file.

Thank you. I wrote img tag and src attribute. but it deleted automatically, when I post topic.

Then repost. And please remember to annotate code and codelike snippets accordingly using markdown syntax:


This `inline` code

```go
// And this is a block of go code
```

Thank you.
I just found the solution.
I added
http.Handle("/temp-images/", http.StripPrefix("/temp-images", http.FileServer(http.Dir(“temp-images/”))));

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.