Accessing Files Outside Root Directory in Magento CE 1.9.0.1

ce-1.9.0.1PHP

I've installed magento and cakephp in my development server. I built a STL viewer by using cake php and gave path like this to upload files to STL viewer:

$mystlpath = $_SERVER['DOCUMENT_ROOT']."dastl/app/webroot/uploads/".$filetoinsertpost;

Now I want STL viewer to access STL files stored in magento directory. It is like accessing files from different directory which is outside root directory. How can I give a path so that STL viewer can access stl files from magento directory?
Can I try like this?

$mystlpath = $_SERVER['DOCUMENT_ROOT']."/../path_to_magento/".$filetoinsertpost;

Here is file structure to make this question more clear:

server root directory
           |www
               |dastl
               |magento

Best Answer

From this question you can do:

dirname(dirname(__FILE__));

Or:

dirname(__FILE__) . '/..';

...but in a web server environment you will probably find that you are already working from current file's working directory, so you can probably just use:

'../'

...to reference the directory above. You can also replace dirname(FILE) with DIR from PHP 5.3.0 onwards

Related Topic