You can change the working directory using chdir().
PHP chdir() function syntax has the following syntax.
chdir(newDir)
newDir is the new directory to change.
chdir() returns true on success or false on failure.
Change the working directory using chdir()
<?PHP
$original_dir = getcwd();
chdir("/etc");
$passwd = fopen("passwd", "r");
fclose($passwd);
chdir($original_dir);
?>
The following code shows how to change the current directory.
//ww w.ja v a 2 s . c o m
<?php
// Get current directory
echo getcwd() . "<br>";
// Change directory
chdir("images");
// Get current directory
echo getcwd();
?>