HTML image not showing while src url working

<img class="sealImage" alt="Image of Seal" src="file:///C:/Users/Anna/Pictures/Nikon%20Transfer/SEALS%20PROJECT/j3evn.jpg"> 

This does not display the image, just alt. But if I go to

 file:///C:/Users/Anna/Pictures/Nikon%20Transfer/SEALS%20PROJECT/j3evn.jpg 

the image is displayed in the browser.

I am posting this on xampp, on a windows machine right now.

I tried different browsers, with and without% 20 for space, but I know that with the right way. (He worked with both, in fact)

And I know that images will only be visible on the machine on which it is located, which is not a problem.

+6
source share
5 answers

Your file should be located inside your www directory. For example, if you use the Wamp server on Windows, you should find j3evn.jpg,

 C:/wamp/www/img/j3evn.jpg 

and you can access it in html via

 <img class="sealImage" alt="Image of Seal" src="../img/j3evn.jpg"> 

Find the www, public_html or html folder that belongs to your web server. Put all your files and resources in this folder.

Hope this helps!

+9
source

My images did not appear even after placing them in the correct folder, the problem is that they did not have the correct permission, I changed the write permission to execute execute. I used chmod 777 image.png. Then everything worked, images were displayed. :)

+3
source

This does not work because you are using the URL link with the file: //. Instead, you should map your directory to your HTML file, for example:

Let's say my file is placed in:

 C:/myuser/project/file.html 

And my desired image is in:

 C:/myuser/project2/image.png 

All I need to do is map the directory as follows:

 <img src="../project2/image.png" /> 
+2
source

my problem did not include ../ before the image name

 background-image: url("../image.png"); 
+1
source

You can try just placing the image in the source directory. You would link it by replacing the path to the src="../imagenamehere.fileextension In your case, j3evn.jpg.

0
source

Source: https://habr.com/ru/post/952403/


All Articles