Absolute file path

This problem is still not resolved.

In the PHP tutorial for PHP that I am participating in, a file called initialize.php is created in which it uses the predefined directory constant Directory_Separator, and then defines site_root. Site_root is the absolute path to the file (not the path to the web server) for PHP to find the files it needs. He gave us the following code

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);

    defined('SITE_ROOT') ? null :
    define ('SITE_ROOT', DS.'Users'.DS.'kevin'.DS.'Sites'.DS.'photo_gallery');

I assume the path to the file on his computer is root / users / kevin / sites / photogallery

I do not build a site on my computer, but rather on the Internet. I do not know which file path to insert.

As he stressed, this is not the path of the web server, but the path to the file system, which I set instead. Just a domain name like this.

define('SITE_ROOT', DS. 'www.example.com');

He does not want the path to the web server, but the files are on the Internet? therefore I do not understand.

UPDATE

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);

defined('SITE_ROOT') ? null :
define ('SITE_ROOT', DS.'Users'.DS.'kevin'.DS.'Sites'.DS.'photo_gallery');
defined('LIB_PATH') ? null : define('LIB_PATH',SITE_ROOT.DS.'includes');

:

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);

defined('SITE_ROOT')? null: define('SITE_ROOT', realpath(dirname(__FILE__)));
defined('LIB_PATH') ? null : define('LIB_PATH',SITE_ROOT.DS.'includes');

require_once (/hsphere/local/home/c263430/quoralist.com/includes/includes/config.php): : /hsphere/local/home/c 263430/quoralist.com/includes/initialize.php on line 11 : require_once(): '/hsphere/local/home/c263430/quoralist.com/includes/includes/config.php' (Include_path = ':/Hsphere/Shared/Apache/libexec/php5ext/PHP/') /hsphere/local/home/c 263430/quoralist.com/includes/initialize.php 11

UPDATE 3 X,

define('SITE_ROOT', DS.'hsphere'.DS.'local'.DS.'home'.DS.'c263430'.DS.'quoralist.com');

: require_once (LIB_PATH/config.php): : /hsphere/local/home/c 263430/quoralist.com/includes/initialize.php on line 11 : require_once(): 'LIB_PATH/config.php' (Include_path = ':/Hsphere/Shared/Apache/libexec/php5ext/PHP/') /hsphere/local/home/c 263430/quoralist.com/includes/initialize.php 11

,

+5
2

defined('SITE_ROOT')? null: define('SITE_ROOT', realpath(dirname(__FILE__)));

echo SITE_ROOT;

define('SITE_ROOT', 'www.domain.com') define('SITE_ROOT', realpath(dirname(__FILE__)).

www.domain.com - url ( ), realpath(dirname(__FILE__)) - FILE, . , - .

: unlink('www.example.com\img1.jpg') img1

unlink(SITE_ROOT.DS.'img1.jpg');

move_uploaded_file . .. ( PHP ), .

, .

[]

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);

defined('SITE_ROOT') ? null : 
    define ('SITE_ROOT', DS.'Users'.DS.'kevin'.DS.'Sites'.DS.'photo_gallery');

mac, web-root Users/kevin/Sites/ Mac, Users/kevin/Sites/photogallery - .

, . , -,

defined('SITE_ROOT')? null: define('SITE_ROOT', realpath(dirname(__FILE__)));

.

DS, (DIRECTORY_SEPARATOR), , DIRECTORY_SEPARATOR . .

  SITE_ROOT'.DIRECTORY_SEPARATOR.'Users'.DIRECTORY_SEPARATOR.'kevin'.DIRECTORY_SEPARATOR.'Sites'.DIRECTORY_SEPARATOR.'photo_gallery'

, ,

defined('DS')? null: define('DS', DIRECTORY_SEPARATOR);
defined('SITE_ROOT')? null: define('SITE_ROOT', realpath(dirname(__FILE__)));

MAC DIRECTORY_SEPARATOR, /. localhost, -,

[: ]

, includes/initialize.php , SITE_ROOT yourwebroot/yourproject/includes, yourwebroot/yourproject/includes.

:

initialize.php yourwebroot/yourproject

defined('SITE_ROOT')? null: define('SITE_ROOT', realpath(dirname(__FILE__)).DS."..".DS);

defined('SITE_ROOT')? null: define('SITE_ROOT', DS.'..'.DS.realpath(dirname(__FILE__)));

( , )

defined('SITE_ROOT')? null: define('SITE_ROOT', '/../'.realpath(dirname(__FILE__)));
+10

, IMAGES,

.php, DS

public function image_path() {
  return $this->upload_dir.$this->filename;
}

:

defined('SITE_ROOT')? null: define('SITE_ROOT', realpath(dirname(__FILE__)).DS."..".DS);

!

+1

All Articles