ainoy31 Posted April 15, 2011 Share Posted April 15, 2011 Directory structure: /home/~test/public_html/soap/ .../xml/ .../bin/ .../products/browser/ In file /home/~test/public_html/soap/bin/products/browser/test.php, I include another file and call it's function: require("../../xml/processXML.php"); $xmlData = generateXML(....); In the /home/~test/public_html/soap/xml/processXML.php, I have the following code: function generateXML() { exec("../bin/code.cur"); } The problem is the exec("../bin/code.cur") fails of the relative path issue. I did a getcwd() before the exec() and it returned /home/~test/public_html/soap/bin/products/browser. I have tried using dirname() and no help. I hope this is clear enought to understand where I am coming from. Thank you. AM Link to comment https://forums.phpfreaks.com/topic/233856-relative-path/ Share on other sites More sharing options...
analog Posted April 15, 2011 Share Posted April 15, 2011 You could change the CWD to the directory of the current file using __FILE__ like this: <?php $old_dir = getcwd(); chdir(dirname(__FILE__)); echo getcwd(); // do your stuff exec("../bin/code.cur"); chdir($old_dir); echo getcwd(); // all back to what it was again ?> Link to comment https://forums.phpfreaks.com/topic/233856-relative-path/#findComment-1202175 Share on other sites More sharing options...
ainoy31 Posted April 15, 2011 Author Share Posted April 15, 2011 thanks man. that helped. Link to comment https://forums.phpfreaks.com/topic/233856-relative-path/#findComment-1202203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.