SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
-
Jul 1, 2009, 02:13 #1
- Join Date
- Oct 2004
- Location
- uk
- Posts
- 853
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
copying contents of folders to another
Hi guys. This is the script I am using to move files from one folder to another.
PHP Code:$foldername=$_POST['foldername'];
if(!file_exists($foldername)) {
mkdir("$foldername/", 0777);
}
$source = '../files';
$dest= "$foldername";
$handle = opendir($source);
// Loop through all files in dir
while (false !== ($file = readdir($handle))) {
copy($file, $dest . '/' . $file);
}
closedir($handle);
}
The issue is it moves all the files over fine but the folders dont get moved over
What could cause this?
Regards
Chris
-
Jul 1, 2009, 02:17 #2
- Join Date
- Apr 2008
- Location
- North-East, UK.
- Posts
- 6,111
- Mentioned
- 3 Post(s)
- Tagged
- 0 Thread(s)
Hi Chris,
You need to recursively iterate the folder structure, check out this example.
Anthony.@AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.
Bookmarks