Working with directories
Directories: Open, read, close and view a list of files
An explanation of how to open a directory, read the contents of a directory, and close a directory.
Function opendir (string path)
The opendir() function opens a directory. It takes the path of the directory (can be just the name of the directory) as its parameter, and returns a directory handle that can be used by
the closedir(), readdir(), and rewinddir() functions.
Example:
$dir = opendir("test");
Creating and deleting directories
Script showing how to create/delete directory
Migrated forum post
Script showing how to create/delete dirs.
Code:
This creates a directory that has a mode of 777.
PHP Code:
<?php if ($makedir == "MakeDir") { $newdir = "$dirname"; $dirmake = mkdir("$newdir", 0777); print "<a href="$newdir">View New Directory</a>n"; } ?> <form action="<? $PHP_SELF; ?>"> <input type="text" name="dirname"> <input type="submit" name="makedir" value="MakeDir"> </form>