View Full Version : move, rename and copy folders
04-10-2003, 11:47 PM
Is it possible to move, rename and copy folders using PHP?
04-10-2003, 11:57 PM
I am not so sure about all that, I have heard that you can copy which means you can create a new name for the file/folder...but I would search for this thread...I read it before...but then again, I don't think you can just move stuff cause that would create some massive problems.
04-11-2003, 07:47 AM
You can copy, but I dont know if you can copy entire folders, I have never tried:
$error = '';
$error .= 'Failed to Create Directory<br />';
for($i = 0; $i < count($file); $i++)
$error .= 'File '.$file[$i].' copied<br />';
$error .= 'Error copying '.$file[$i].'<br />';
$filename = array('file1.txt','file2.txt','file3.txt');
$foldername = "folder";
$destination = "anotherfolder";
$uploads = copyFF($filename,$foldername,$destination);
echo $uploads; // Prints any errors
I just quickly wrote this function, so there may be some errors, but that would have the effect of copying a dir and any files within it.
04-11-2003, 07:48 AM
Just an afterthought, you said you wanted to move the directory completely, you might want to add rmdir() into that function ( if it even works :D )
04-11-2003, 12:22 PM
I was wondering if there was a built in function to do it. I'm guesssing the isn't. Thanks for the script, but I doubt it would be very usefull if there was another directory withing the directory I want to move. I guess I could write a code that maps out the filesystem below the folder I select, creates all the folders withing it, move all the files within them to the new destination (with rename()), then go delete all the folders, one at a time from the lowest point in the branch up. At this point it's not that it would be a very hard script to write, it's that I think it would use too much of the servers ressources. Thanks everyone for the help, but I think I'm just going to forget about this function for now.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.