0

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
  • Are you trying to load your files from Magento into STL or the other way around? – brentwpeterson Jul 15 '14 at 13:06
  • Trying to load from magento to STL – brainReader Jul 15 '14 at 13:10
  • So this really isn't a Magento question. – brentwpeterson Jul 15 '14 at 19:23
  • That is why I asked it in webmasters.stackexchange and it was migrated here – brainReader Jul 16 '14 at 4:34
1

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

| improve this answer | |
  • I tried ..\ method, it didn't work. Should try dirname() method – brainReader Jul 15 '14 at 12:27
  • Dont use \, try with /. Its not the same. – mbalparda Jul 15 '14 at 12:44
  • Yeah, I tried ../, it didn't work. This is the error which I got: failed to open stream, no such directory – brainReader Jul 15 '14 at 12:48
  • Can you tell me more accurately that how can I use it? – brainReader Jul 15 '14 at 13:05
  • Try this die(var_dump($_SERVER)) and paste it here. We are looking for $_SERVER["DOCUMENT_ROOT"] exactly. – mbalparda Jul 15 '14 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.