Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Issue to page

Hi,
Jpg file does exist in "/var/www/pict" path, but html file below is not able to show Jpg file. Why?

<html>
    <body>
        <!--div align="center"-->
        <div class="container" style="background:url('../pict/ID-10028343.jpg') no-repeat center top; Height:780px; Width:1220px; background-size:100% 100%; margin:0 auto; ">
        ...

Open in new window

Avatar of Dr. Klahn
Dr. Klahn

If the server is rooted at "/var/www", then remove the ".." and it should work.

Side note:  Path-relative file locations can cause trouble in HTML, and particularly so (n) years down the road when things are rearranged.  Better to keep image files in the same locations as the HTML files which use them, or in dedicated subdirectories e.g., "/graphics/standard/image32.png"
Avatar of Peter Chan

ASKER

I removed ".." but no improvement. How to check if it is rooted at "/var/www"?
without knowing where your HTML file in relation to the pict folder it is hard to answer.

Commonly, the baseline of content is in /var/www/html root of the default web site.

/var/www is outside the web servers data such that placing pict here, and then an index.html in /var/www/html will never reach it

i.e. while you think ../pict from html will be valid, within the web server the index.html is at / and ../ still means /.

i.e. cd /
cd ../
pwd
meaning in the web server your /var/www/html is the root / your html page says ../pict is being translated /pict which is  /var/www/html/pict within the file system. Based on your description, the pict folder under /var/www/html/ does not exist and thus the error 403/4 no such directory or file......
If you have access to the shell
1 - what is rtge address of your web page? in most situarions would be /var/www/ or (on recent systelms) /var/www/html/ )
2 - what are the access rights and owner of your jpg file? in most cases owners would be www-data:www-data and rwxr-xr-x (or 755)
Currently, Html file is in path below

/var/www/html

Why ../pict is not able to locate

/var/www/pict

path?
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial