-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkdir.php
More file actions
40 lines (35 loc) · 1.16 KB
/
mkdir.php
File metadata and controls
40 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
include("models/db-settings.php");
include("models/config.php");
$foldername = $_POST["foldername"];
$filename = $foldername;
$path = __DIR__ . "/Systems" . $loggedInUser->username;
$fullPath = $path . "/" . $filename;
if (!file_exists($fullPath)){
mkdir($fullPath, 0777);
echo "The directory was successfully created.";
}
echo $fullPath;
function recursiveCopy($source, $destination)
{
if (!file_exists($destination)) {
mkdir($destination);
}
$splFileInfoArr = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST);
foreach ($splFileInfoArr as $fullPath => $splFileinfo) {
//skip . ..
if (in_array($splFileinfo->getBasename(), [".", ".."])) {
continue;
}
//get relative path of source file or folder
$path = str_replace($source, "", $splFileinfo->getPathname());
if ($splFileinfo->isDir()) {
mkdir($destination . "/" . $path);
} else {
copy($fullPath, $destination . "/" . $path);
}
}
}
#calling the function
recursiveCopy(__DIR__ . "/stock/stocksystem", $fullPath);
?>