jemz
1
Hi,
I need some help about the path i don’t know how can i access this in php
this is the path c:\wamp\www\first_folder\second_folder\ hird_folder\image.jpg
src=“…/third_folder/image.jpg”
but i could not display the image…what is the correct way in accessing my image thank you in advance.
It depends where the code is relative to the image. In what folder is the code file stored that contains src=“…/third_folder/image.jpg” ?
jemz
3
The php code is in the first_folder and the image.jpg is in the third_folder.
Then try
src="second_folder/third_folder/image.jpg"
jemz
5
why not like this
src=“…/second_folder/third_folder/image.jpg” ?
Why would you want to add ‘…/’ ? Do you know what that means?
jemz
7
Hi, sorry for the late reply,to be honest i don’t know what this means “…/”,can you please enlighten my mind on what it means.
By the way it’s working i tried your solution thank you so much for helping me.
Cups
8
If this is the real path of your files…
c:\wamp\www\first_folder\second_folder\ hird_folder\image.jpg
And the home page of your website is served from :
c:\wamp\www\
Then your html should reference it from that home page by adding a slash before the path of the requested file :
<img src = “/fiirst_folder/second_folder/third_folder/image.jpg” />
Then it matters naught where the webpage is served from on that website.
You need to read up on the [google]difference between relative and absolute path[/google].
ps
…/ means go up one directory from where I am now.
…/images means go up one directory from where I am now, then go down into a directory called images
These are relative links (relative to where I am now)
jemz
9
Hi cups, Thank you for enlighten my mind…it helps me.
Hi @jemz,
I have struggled with paths and now define all paths in a constant.php. The file is then included:
constants.php
# constants
define('LOCALHOST', in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1') ));
if(LOCALHOST)
{
$tmp = "c:\\wamp\\www\\first_folder\\second_folder\ hird_folder\\";
define('THUMB_PATH', substr($tmp,2) );
define('THUMB_URL', "http://subdomain.localhost/thumb/");
}
else
{
define('THUMB_PATH', "/home/content/42/558877/html/ci_john/subdomain/thumb/');" );
define('THUMB_URL', "http://subdomain.Johns-Jokes.com/thumb/");
}
usage: - works both for LOCALHOST and Online
require_once 'constants';
echo "<img src='" .THUMB_URL ."image.jpg' style='border:0' alt='whatever' />";
jemz
11
Hi,Thank you so much for this,and for helping me…I give a try on this.