Files and Directories
|
|
|
|
<?php /*
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' File: xcopy.php
'
' Description: Xcopy in PHP
' Written by: Imran Khalid imranlink@hotmail.com
'
' Languages: PHP
'
' Date Written: June 14, 2003
'
' Date Modify: June 14, 2003
'
' Platform: Linux
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
*/
$basedir = "techbuys/"; // Please set your basedir.
$txtFolderName = "past_inside_me"; // Folder name where u want to copy the files.
$dirPathTarget = "c:/inetpub/wwwroot/". $txtFolderName; // edit the root path according to your server OS.
$dirPathSource = "c:/inetpub/wwwroot/shoppingclone/techbuys"; // change according to your requirements.
xcopy($basedir,$txtFolderName);
///////////////////////////////////////////////////////////////////////////////////////////////////// function xcopy($basedir,$txtFolderName){
if ($handle = @opendir($basedir)) {
while (false !== ($dir = readdir($handle))){
if ($dir != '.' && $dir != '..'){
$pos = strpos ( $basedir, "/");
$newdir = substr($basedir, $pos);
$pos = strpos ( $newdir, "/");
$newdir = substr($newdir, $pos+1);
$pos = strpos ( $newdir, "/");
$dirPathTarget = "c:/inetpub/wwwroot/". $txtFolderName ."/". $newdir ."/". $dir; // edit the root path according to your server OS.
$dirPathSource = "c:/inetpub/wwwroot/shoppingclone/techbuys/". $newdir ."/". $dir; // edit the root path according to your server OS.
$dirPathTarget = str_replace("//","/",$dirPathTarget);
$dirPathSource = str_replace("//","/",$dirPathSource);
if (is_dir($basedir."/".$dir)){
$mkSuccess = mkdir($dirPathTarget);
xcopy($basedir."/".$dir,$txtFolderName);
}
else{
echo "$dirPathTarget<br>";
copy($dirPathSource, $dirPathTarget);
}
}
}
closedir($handle);
}
} ////////////////////////////////////////////////////////////////////////////////////////////////
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|