cedricganon Posted November 25, 2011 Share Posted November 25, 2011 Hello So in my index.php code i include('somefile.html');. In the html file itself there is an <img src="/images/picture.jpg">. When looking at index.php on a browser, the html looks fine everything loaded fine except for the <img> There is a little broken image link displayed on the page. i checked through the browser if i mistyped the img src link but somefile.html in the browser displays the image fine. But if i try to display the img in the html file through the php file, its a broken link. Any reason why this is happening? Am I missing something here? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Spring Posted November 25, 2011 Share Posted November 25, 2011 is somefile.html in a separate folder than index.php? Quote Link to comment Share on other sites More sharing options...
cedricganon Posted November 25, 2011 Author Share Posted November 25, 2011 yes it is. to give you an idea of the structure its something like this: index.php: root folder somefile.html: /dir1/dir2/somefile.html picture.jpg: /dir1/dir2/images/picture.jpg the images folder is located in the same folder as somefile.html. I've tried using a path relative to the root folder for the image ie: <img src='/dir1/dir2/images/picture.jpg'> as opposed to a path relative to somefile.html: <img src='/images/picture.jpg'> neither presents an image Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 25, 2011 Share Posted November 25, 2011 A leading slash on a link/URL refers to the root of the domain (i.e. a domain relative link/URL.) All the URL's you have shown in your post are trying to find the file starting at your domain root - http://yourdomain.com/images/picture.jpg http://yourdomain.com/dir1/dir2/images/picture.jpg Relative URL's either start with a dot or double-dot or are just the filename. Quote Link to comment Share on other sites More sharing options...
cedricganon Posted November 25, 2011 Author Share Posted November 25, 2011 fixed it! Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.