0

I try to add image in html with full path. I google the problem and found this src absolute path problem and I try every answer, but does not work for me.

This is my code, do you have any idea, why image is not found?

<img src="file://C:/Storage/Images/a.png" alt="las vegas" width="200" height="200">

1 Answers1

1
  1. open the folder explorer

enter image description here

  1. click right-click on the image in the file explorer
    you will see a dropdown with some buttons

  2. click the "copy path"

enter image description here

  1. now we need to add the link to the src attribute

  2. write file:/// (3 slash /)

  3. paste the copied path after file:///

file:///"C:\Users\laaou\Downloads\1280px-Stack_Overflow_logo.svg.png"
  1. delete the " character at the start and at the end "
file:///C:\Users\laaou\Downloads\1280px-Stack_Overflow_logo.svg.png
  1. like he said @mplungjan change the \ to / (see his first comment)

you can use an online tool like this http://www.unit-conversion.info/texttools/replace-text/ (if you have long links)

  1. here is the final HTML
<img src="file:///C:/Users/laaou/Downloads/1280px-Stack_Overflow_logo.svg.png">

alternative ways

but still better to put the images in the same folder where there is the index.html

so you just need to write

  1. ./imageName.png
  2. or ./MyFolder/imageName.png

or host your image in a service like Imgur

and write that link inside the src

the link it will be like this: https://i.stack.imgur.com/PRUS3.png

<img src="https://i.stack.imgur.com/PRUS3.png">
Laaouatni Anas
  • 4,199
  • 2
  • 7
  • 26