alant Posted December 27, 2006 Share Posted December 27, 2006 I'm getting quite frustrated with my chdir function not actually changing the dir on my site. Here's the test code I'm using:[code]<?phpecho(dirname(__FILE__));chdir(dirname(__FILE__));echo getcwd();?>[/code]When I echo (dirname(__FILE__)) it correctly echoes the path in which my script is running which is C:\www. But when it gets to echo getcwd() it either echoes C:\www\resources or C:\windows\system32 and when I refresh the page it will occasionally flick back and forth between those two. Why doesn't it change the directory to C:\www like I asked it too? Quote Link to comment Share on other sites More sharing options...
trq Posted December 27, 2006 Share Posted December 27, 2006 I don't see the point in chaning directory to the current directory. What exactly are you trying to do? Quote Link to comment Share on other sites More sharing options...
alant Posted December 27, 2006 Author Share Posted December 27, 2006 well I need to change to the current directory because for some reason the current working directory being reported by getcwd() isn't the directory that my index.php is in. So whenever I want to include another php file or something, instead of it looking for the file relative to my index.php it looks for it under c:\www\resources. My index.php script is located in C:\www not C:\www\resources. Quote Link to comment Share on other sites More sharing options...
trq Posted December 27, 2006 Share Posted December 27, 2006 Im not sure your going abou this the correct way. Maybe $_SERVER['DOCUMENT_ROOT'] will help you. Quote Link to comment Share on other sites More sharing options...
alant Posted December 27, 2006 Author Share Posted December 27, 2006 no that doesn't work either, I tried that first. for some reason unknown to me it doesn't want to change my directory, it's beyond me why it is defaulting to my c:\www\resources directory in the first place I have no links to it in my index.php whatsoever. I have a feeling it has something to do with IIS so I've installed apache and will give that a go tomorrow. Quote Link to comment Share on other sites More sharing options...
alant Posted December 27, 2006 Author Share Posted December 27, 2006 Problem solved. Apache works flawlessly and sets the working dir to the same dir the script is run from. I'm still curious as to why IIS was struggling though. Quote Link to comment Share on other sites More sharing options...
trq Posted December 27, 2006 Share Posted December 27, 2006 [quote]I'm still curious as to why IIS was struggling though.[/quote]Probably because its made by MS. :-P Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted December 27, 2006 Share Posted December 27, 2006 [quote author=thorpe link=topic=119999.msg492309#msg492309 date=1167256255][quote]I'm still curious as to why IIS was struggling though.[/quote]Probably because its made by MS. :-P[/quote]EXACTLY. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.