copy files...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
th3monk3y
Forum Commoner
Posts: 29
Joined: Thu Jun 19, 2003 10:34 pm

copy files...

Post by th3monk3y »

Hi all,
I am looking for a snippet of code to copy all files from one directory to another (same server).. Probably not too hard.. just can't seem to find any examples...
-P
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

untested stab in the dark

Code: Select all

$files = glob("/path/to/source/dir/*.*");
foreach($files as $source)
{
  copy($source,"/path/to/destination/".basename($source));
}
th3monk3y
Forum Commoner
Posts: 29
Joined: Thu Jun 19, 2003 10:34 pm

Post by th3monk3y »

thanks for the quick reply feyd.. getting the following error..

Call to undefined function: glob()

-Paul
th3monk3y
Forum Commoner
Posts: 29
Joined: Thu Jun 19, 2003 10:34 pm

Post by th3monk3y »

Apparently glob() will not work with my version of php which is 4.2.2
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

wow, old version..

k, use opendir() & readdir() instead.
Post Reply