gingera
asked on
PHP Linux: How to copy a file to multiple directories?
PHP Linux
Hello,
How do I copy a file to multiple directories (either through command line or through a PHP script)?
For example...
I want to copy a specific file, index.php in /universal/
to these directories
/storage/A
/storage/B
/storage/C
/storage/D
How do I achieve that?
Hello,
How do I copy a file to multiple directories (either through command line or through a PHP script)?
For example...
I want to copy a specific file, index.php in /universal/
to these directories
/storage/A
/storage/B
/storage/C
/storage/D
How do I achieve that?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi afzz, your suggested solution sounds feasible.
The file has to be copied to hundreds of directories. Could I use a MySQL database to feed this line:
$dest=array("/storage/A"," /storage/B ","/storag e/C","/sto rage/D");
If so, how? (I am a newbie). Thanks.
The file has to be copied to hundreds of directories. Could I use a MySQL database to feed this line:
$dest=array("/storage/A","
If so, how? (I am a newbie). Thanks.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks afzz and Xorlev! Your combined suggestion worked OK to copy 1 file.
What if I want to copy multiple files at the same time? Can I use an array for $filelist as well? If so, how do I change afzz's code to accommodate the array?
e.g.
$filelist = array("index1.php","index2 .php","ind ex3.php"," index4.php ","index5. php","inde x6.php");
What if I want to copy multiple files at the same time? Can I use an array for $filelist as well? If so, how do I change afzz's code to accommodate the array?
e.g.
$filelist = array("index1.php","index2
ASKER
THANKS!
I hope this is what you're looking for.
Open in new window