Reputation: 75
This is the path of my html file ie test.html
/var/www/html/1/2/3/4/5/6/7/8/9/test.html
i want images from this path:
/var/www/html/1/2/3/4
How i able to do in img tag, src attribute.
Upvotes: 0
Views: 2803
Reputation: 1272
You should take a look at Absolute and Relative Paths
in your case writing <img src="."/>
is your current path so it's equivalent to /var/www/html/1/2/3/4/5/6/7/8/9/test.html (.
means current directory)
now you can go some directories up using "..
" so you can move up to your desired path using this method : <img src="../../../../../img.jpg">
These two methods are called Relative paths and that's what you should use in your websites since you can sometimes have to migrate your website and absolute paths wouldn't work anymore
For example if you write
<img src="http://html/1/2/3/4/img.jpg"/>
it would still work but only if your site is named "html" and the directory logic stays the same
hope it helped !
Upvotes: 2
Reputation: 172
Hope i understand your question. The path should be like this
../../../../../img.jpg
each ../
will take you back to one folder .. Could you try this..
Upvotes: 1
Reputation: 27082
Use relative path, ..
means dir up, so the path in index.html to img.jpg has to be:
<img src="../../../../../img.jpg">
Upvotes: 0