Adsense
Popular Posts
Thursday, November 14, 2013
PHP, copy directory
The following PHP function copys is used to copy entire directories
* Allows the copying of entire directories.
* @access public
* @param string $source the source directory
* @param string $dest the destination directory
* @return boolean whether the copy was successful or not
function copys($source,$dest)
{
if (!is_dir($source)) {
return false;
}
if (!is_dir($dest)) {
mkdir($dest);
}
$h=@dir($source);
while (@($entry=$h->read()) !== false) {
if (($entry == '.') || ($entry == '..')) {
continue;
}
if (is_dir("$source/$entry") && $dest!=="$source/$entry") {
copys("$source/$entry", "$dest/$entry");
} else {
@copy("$source/$entry", "$dest/$entry");
}
}
$h->close();
return true;
}
Labels:
php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment