This is a file directory move class, as long as in Listdir write your file to transfer the directory name moved on it, this folder and file move class, more suitable for the collection of multiple files to download the operation, such as in the packaging file add instructions, etc. oh.
<?php Tutorial
Die ();
Class s{
var $path = ' flash ';
var $htm = '/index.htm ';
var $html = '/index.html ';
var $ladir = '/111cn.net tutorial ';
Public Function Full_copy ($source, $target)
{
if (Is_dir ($source) && $source!= $source. $this->ladir)
{
@mkdir ($target);
$d = Dir ($source);
while (FALSE!== ($entry = $d->read ()))
{
if ($entry = = '. ' | | $entry = = ' ... ')
{
Continue
}
$Entry = $source. '/' . $entry;
if (Is_dir ($Entry))
{
$this->full_copy ($Entry, $target. '/' . $entry);
Continue
}
Copy ($Entry, $target. '/' . $entry);
}
$d->close ();
}
Else
{
Copy ($source, $target);
}
}
//
Public Function Listdir ($dir _path)
{
if (Is_dir ($dir _path)) {
if ($dir _file=opendir ($dir _path)) {
while (($dir _list=readdir ($dir _file))!==false)
{
if ($dir _list!= "." && $dir _list!= "...")
{
$this->listsundir ($dir _path.) /". $dir _list);
$this->mkdir_r ($dir _path.) /". $dir _list. $this->ladir);
}
}
}else{
Echo ($dir _path);
}
}else{
Echo ($dir _path);
}
}
//
Public Function Listsundir ($dir _path)
{
if (Is_dir ($dir _path)) {
if ($dir _file=opendir ($dir _path)) {
while (($dir _list=readdir ($dir _file))!==false)
{
if ($dir _list!= "." && $dir _list!= "...")
{
$this->mkdir_r ($dir _path.) /". $dir _list. $this->ladir);
if ('/'. $dir _list = = $this->ladir)
{
Continue
}
Else
{
Echo $dir _path. " /". $dir _list, ' <br/> ';
$this->full_copy ($dir _path.) /". $dir _list, $dir _path." /". $this->ladir);
$this->deldir ($dir _path.) /". $dir _list);
}
$this->full_copy ($dir _path.) /". $dir _list, $dir _path." /". $dir _list. $this->ladir);
}
}
}else{
Echo ($dir _path);
}
}else{
Echo ($dir _path);
}
}
//
Public Function checkfile ($dir)
{
if (Is_dir ($dir))
{
if (Is_file ($dir. $htm) | | is_file ($dir. $html))
{
Continue
}
Else
{
$this->full_copy ($dir, $target);
}
}
}
Mkdir
function Mkdir_r ($dirName, $rights =0777)
{
$dirs = explode ('/', $dirName);
$dir = ';
foreach ($dirs as $part) {
$dir. = $part. ' /';
if (!is_dir ($dir) && strlen ($dir) >0 &&!is_file ($dirName))
{
mkdir ($dir, $rights);
echo "$dirName <br/>";
}
}
}
Delall
function Deldir ($dir)
{
if (Is_dir ($dir))
{
$rdir = $dir;
if ($dirlist = Scandir ($rdir))
{
Array_shift ($dirlist);
Array_shift ($dirlist);
foreach ($dirlist as $d) {
$rd = $rdir. ' /'. $d;
if (Isset ($d) && is_file ($rd)) {
Unlink ($RD);
}else{
$this->deldir ($RD);
}
}
RmDir ($rdir);
}else{
return false;
}
}
return true;
}
}
$s = new S ();
$s->listdir (' flash ');//To move the directory
?>