I have a img
tag with src = "file:///C:/Users/king/Documents/testing.jpg"
. This tag is not showing the image . Whats the problem ?

- 2,855
- 5
- 28
- 39
-
Did you tried to quote a path? – fedosov Jul 16 '12 at 15:01
-
I guess the image is not loaded, did you try to set an "alt" test and see if it appears ? – Julien Ch. Jul 16 '12 at 15:02
-
4you should provide more context, and a real excerpt from your HTML. – Julien Ch. Jul 16 '12 at 15:04
-
Related? [Why can't I do
?](http://stackoverflow.com/questions/4090712/why-cant-i-do-img-src-c-localfile-jpg) – Jul 16 '12 at 15:19
7 Answers
img
tag doesn't have a href
attribute.. that's for links.
- Use
src="image path here"
instead. The full tag is<img src="path" alt="alt text" />
- Make sure the path leads to a valid file
- Put the path in quotes
- Know that it will display a file from your computer and this will only work if the HTML page is locally stored on your computer.

- 30,730
- 8
- 78
- 73
The problem might be arising because the address that you have goes to a file on your computer. If someone else is trying to access this page from a webserver, they most likely will not have your file at that same location on their computer.

- 1,498
- 1
- 14
- 22
<a href="file:///C:/Users/King/Documents/testing.jpg"><img src="file:///C:/Users/King/Documents/testing.jpg" /></a>
Must work
Be sure if testing.jpg is there.. Maybe is testing.JPG ..

- 11
- 1
<img src="path/to/file.jpg" alt="This is my image" />
is a correct tag...try that instead
And you cant use a local path like that, it goes to a file on your harddrive, nobody else can access it if you put it online. Use a relative link instead like "rootfolder/images/yourimage.jpg"

- 9,781
- 9
- 49
- 67
Due to security reasons, I'm not sure if a browswer can always access a protocol of file:// are you running on localhost? If not that is your reason. I would advise you to always use relational URLS if possible so if your HTML is in Documents then src="testing.jpg" would be fine.
In general I would recommend having the images in a subfolder of where your index file is to make it easier and to allow relative urls such as "./images/testing.jpg" or "../images/testing.jpg".

- 3,260
- 4
- 27
- 55
use relative paths as opposed to absolute for example if the image file was to folders above where the place you are storing your webpage at use ../../testing.jpg

- 1,556
- 4
- 26
- 42