GoofBall101
GoofBall101

Reputation: 308

Html Image will not load under any change - Golang

I am trying to load an image locally onto my html. I first tried serving an image path through a /images/ folder, but that did not work. I then tried serving images with the whole path to the image like <img src="/Users/code/src/code/go/src/websites/website/website-Bucket.png" alt="test"> but I still had no luck. I checked my html and it has no errors. I have restarted my PC, changed the image to .jpg, and it still did not want to work. I get an error in Safari - An error occurred while trying to load the resource and the image shows as a blue box and question mark. What things would you try to troubleshoot?

Extra - I am using goLang to serve the files. I have it so a http.handleFunc() goes off and serves the images folder when it is requested. The path is showing http://localhost/images/theImage.png "the correct path" but nothing happens. So, I save the image and it shows it as a html and shows a section of the page?? Would that be a path thing?

Upvotes: 1

Views: 2041

Answers (4)

GoofBall101
GoofBall101

Reputation: 308

All of your guy's responses were correct. I had the correct path. It was a Golang thing. I did not make a handlefunc when the server wants the /image.png. It was never serving the image, it just was doing nothing with it. Thank you for the responses.

Upvotes: 1

Guille
Guille

Reputation: 652

Open Console in any browser and see if you see any errors that mention not being able to find the source path of the picture.

It should give you a hint of where your browser is trying to find that img.

Upvotes: 1

ShaneCalder
ShaneCalder

Reputation: 346

Looks like it may be a file path issue.
Take a look at this page it has a good example.
https://www.w3schools.com/html/html_filepaths.asp

Also try renaming the image with a _ and not use the -.

Upvotes: 1

balumanzano
balumanzano

Reputation: 178

In first instance you have to understand the path source, when you are on a HTML file, your path inside the file should be :

<img src="images/website-Bucket.png" alt="test">

that's because : the path of your .html file can access trough files the inside path with the "/folder/file" structure route in the html file, so your structure files should be:

  • yourfiel.html (your file render on browser) /imagesfolder

  • -website-Bucket.png" (you call it on your html as

  • /imagesfolder/website/Bucket.png)./

you can learn more about paths here : http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/

Upvotes: 1

Related Questions