Directory copy function to any directory
function Dir1 ($filename, $dest) {
Static $dirname;
$dirname. = $dest;
Connector header (First level directory)
Static $dir;
Intermediate variables
if (file_exists ($filename)) {
If the file exists
if (Is_dir ($filename)) {
If it is a directory, first create the directory and then traverse
$dirnames =basename ($filename);
Take the final directory or file name and link to the first level directory you want to transfer to
$dirname. = '/'. $dirnames;
Get the total path by constantly stacking
$dir = $dirname;
Short-circuit operation
Is_dir ($dirname) | | mkdir ($dirname, 0007,true);
Traverse Directory
$file =glob ($filename. ' /*‘);
foreach ($file as $value) {
Take the last file name
$files =basename ($value);
Link to last Level
$dir. = '/'. $files;
Recursive invocation
if (Is_dir ($value)) {Dir1 ($value, ');};
if (Is_file ($value)) {
If it is a file, copy it directly
fopen ($dir, ' w ');
Copy ($filename, $dir);
}
$dir =dirname (($dir));
}
}
}
}
Program slightly bloated "_"
All files in the PHP copy directory