Avatar of Peter Chan
Peter Chan
Flag for Hong Kong asked on

Issue to page

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

        <!--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

Web DevelopmentHTMLProgramming Languages-OtherUbuntuLinux

Avatar of undefined
Last Comment

8/22/2022 - Mon
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"
Peter Chan

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 ../
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......
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Bernard Savonet

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)
Peter Chan

Currently, Html file is in path below


Why ../pict is not able to locate



Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question