Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

will this script copy only certain files?

Status
Not open for further replies.

verbatim1

Programmer
Apr 18, 2005
58
US
i want to copy all the files [but none of the folders] from one folder to another.

To copy only the files and not the folders this should work:



Code:
<?php
define('TARGETDIR', '/home/xxx/mainwebsite/new/'');
foreach (glob('/home/abc/dep/*') as $dep) {
    if (is_file($dep))    # Exclude directories
        copy($dep, TARGETDIR . basename($dep));
}
?>


but i get the following error for every file that should be transfered

Warning: copy(/home/abc/dep/*"misc_filename".php): failed to open stream: No such file or directory in /var/ on line 101

line 101 :
Code:
 copy($dep, TARGETDIR . basename($dep));



any quick solutions??
 
edit:

the 2nd "miscfilename.php" in the warning should be "scriptname.php"

as it lists the name of script running
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top