Reputation:
I'm working with chdir() and it's my first time and I'm having problems when I change the directory.
Well, when I change the directory I use chdir(directory_name); but then when I check for the current directory or if I try to access to another directory that exists in the directory that I enter the first time I have an error because the actual directory didn't change
EDIT: Sorry for not show any code but I found the solution. I create a $_SESSION to store the current directory and the new directory when I change it.
if(!isset($_SESSION['dir'])) {
chdir("../../filesystem");
$_SESSION['dir'] = getcwd();
} else {
chdir($_SESSION['dir']);
}
Upvotes: 0
Views: 223
Reputation: 360762
Did you check for success/failure? e.g:
$result = chdir('newdir');
if ($result === false) {
die("Could not chdir()");
}
Upvotes: 2