I am trying to get an image img
to display in an html
element. Everything is saved and run locally using http-server
. I just want to specify a path to the file and it is just for dev purposes. I plan to put all the files on a server when I'm done. In other words, I'm developing a website locally on my PC and testing it as I go because I don't know html very well and when I'm finished I'll transfer all the files over to the hosting companies server and rework the paths. Seems simple enough to me, but no go.
<!DOCTYPE HTML>
<html>
<head>
<title>test-Confluence Infinite International</title>
<style>
#ad_frame{ height:800px; width:100%; }
body{ margin:0; border: 0; padding: 0; }
</style>
</head>
<body>
<img src="file:///C:/Users/Benjamin/Pictures/CII - Logo v6 - 2020-08-02 1219.PNG" alt="test.com" width="104" height="142">
<div>
test2
</div>
</body>
</html>
I'm using a 64-bit Windows 10 PC.
html file is saved in C:/Users/Benjamin/Documents/CII - Website Files - 2020-08-29 2053\Home.html
Image is save here C:/Users/Benjamin/Pictures/CII - Logo v6 - 2020-08-02 1219.PNG
I used this link to get the local server going: How to run html file on localhost?
downloaded node.js from here: https://nodejs.org/en/download/
I ran http-server via cmd and got this:
C:\Users\Benjamin>http-server
Starting up http-server, serving ./
Available on:
http://10.0.1.2:8080
http://127.0.0.1:8080
Hit CTRL-C to stop the server
[2020-08-30T13:05:14.979Z] "GET /" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
(node:3392) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
I found this link, but it doesn't seem to work: https://superuser.com/questions/224500/how-to-display-local-images-in-chrome-using-file-protocol
When I refresh the tab in Chrome I get no errors usually:
[2020-08-30T13:41:12.976Z] "GET /Documents/CII%20-%20Website%20Files%20-%202020-08-29%202053/Home.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36"
What am I doing wrong? I've tried all sorts of variations on the path to the image file.
EDIT1:
I've tried a few things from the comments, but nothing seems to work. I tried saving the image file, the index.html file, and the home.html file in the same location. That didn't help:
<img src="file:///C:/Users/Benjamin/Documents/CII - Website Files - 2020-08-29 2053/CII - Logo v6 - 2020-08-02 1219.PNG" alt="" width="104" height="142">
I also tried "Pictures/CII - Logo v6 - 2020-08-02 1219.PNG"
, but that didn't work.