HTML jpg file path

O

omegaman

Guest
Hello everyone I am new to Linux and HTML hopefully one of you can help me with a simple problem. I am trying to include a .jpg picture in an HTML file but I cant figure out what the path to the picture should be. In windows I would type <img src= "file:/c:/Users/omegaman/desktop/****.jpg"> The distribution is Debian Wheezy and the picture is in the pictures file. It looks like the hard drive is in dev/sda.
Thanks in advance for your help.
 


So, if the picture is in your users Pictures folder it will be at the following location

/home/USERNAME/Pictures/*****.jpg
or
~/Pictures/******.jpg

but for HTML, I would use the full location (the first one)
 
What web server are you using? Probably Apache. And where is your web server's document root? I don't know about Debian, but linux systems often use /var/www/html. That means
<img src="/picture.jpg" /> would have to be in /var/www/html"

Though the document route can also be configured, and is often ~/public_html/ for individual users.

But if the html file and jpg file are in the same directory, you can use a relative path with no leading slash:
<img src="picture.jpg" />
or in a subdirectory of the directory containing the html (again, no leading slash):
<img src="img/picture.jpg" />
 
I have tried all of these suggestions and cant get this to work. I can paste the destination for a picture on the internet and it shows up. I am not able to copy the picture to the var/www file (yes its apache). All I'm doing is modifying the index.html file that is there when you install apache, could that be the problem?
 
Why can't you copy the picutre into your web file?
Any what host are you using for the web server? It sounds like you're trying to link an address from your PC that the server isn't recognizing. If the server isn't running from your Windows PC (assuming based on the c:/ file path you're on Windows) then it won't recognize the file path.

For example, I'm running Tomcat from my current (work) PC, saving a picture into C:\apache-tomcat-xxx\webapps\examples and then editing the index.html file there to include the picture with the relative path should work:
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Apache Tomcat Examples</TITLE>
<META http-equiv=Content-Type content="text/html">
</HEAD>
<BODY>
<P>
<H3>Apache Tomcat Examples</H3>
<P></P>
<ul>
<li><a href="servlets">Servlets examples</a></li>
<li><a href="jsp">JSP Examples</a></li>
<li><a href="websocket">WebSocket Examples</a></li>
</ul>
<img src="mypic.jpg" />        <------- *PICTURE TAG*
</BODY></HTML>

Save the picture in the same folder as your index.html file and USE RELATIVE PATHS whenever possible as it makes moving apps between hosts a LOT easier.

Once you have it working from the same folder you can add a folder in the directory for pics or whatever and reference it as 'src="pics/mypic.jpg"'

-Edit: You also don't need the 'file:' prefix and don't lead the URL with a slash. Assuming everything else is correct, your original tag should be:
HTML:
<img src="c:/Users/omegaman/desktop/****.jpg" />

Again though, you're saying you're on Debian, but are referencing a Windows directory so there is some kind of discrepancy there, but you know your setup better than us.
 
Last edited:

Members online


Latest posts

Top