$folderContent = array();
$startPoint = "e:\\MyWork\\web\\draft\\"; // Путь к исходной папке
$destFolder = "e:\\1"; // к результирующей папке
$folderContent["folderName"] = $startPoint;
$folderContent["type"] = "folder";
$folderContent["items"] = array();
function makeFolderStructure($startFolder, &$folderContent)
{
$startPoint = opendir($startFolder);
while($currentItem = readdir($startPoint))
{
if(($currentItem != ".") && ($currentItem != ".."))
{
if(is_dir($startFolder."\\".$currentItem))
{
array_push
(
$folderContent["items"],
array
(
"folderName" => $currentItem,
"type" => "folder",
"items" => array()
)
);
makeFolderStructure
(
$startFolder."\\".$currentItem,
$folderContent["items"][count($folderContent["items"]) - 1]
);
}
else
{
array_push
(
$folderContent["items"],
array
(
"type" => "file",
"fileName" => $currentItem
)
);
}
}
}
}
function restoreFolderStructure($startFolder, $folderContent)
{
$currentFolder = opendir($startFolder);
foreach($folderContent["items"] as $currentItem)
{
if($currentItem["type"] == "file")
{
$fileHandle = fopen($startFolder."\\".$currentItem["fileName"], "w");
fclose($fileHandle);
}
else
{
mkdir($startFolder."\\".$currentItem["folderName"]);
restoreFolderStructure
(
$startFolder."\\".$currentItem["folderName"],
$currentItem
);
}
}
}
makeFolderStructure($startPoint, $folderContent);
restoreFolderStructure($destFolder, $folderContent);
// echo json_encode($folderContent)."\n";
print_r($folderContent);
1.есть строка в которую вводим адрес ресурса, коннектимся к нему
2. появляется строка поиска вводим название.