how do I copy files from one dir to another?

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
michlcamp
Forum Commoner
Posts: 78
Joined: Mon Jul 18, 2005 11:06 pm

how do I copy files from one dir to another?

Post by michlcamp »

I've created a small php script to create a new directory on the server, and now want to copy five files from one directory (on the same server) to the new directory and also chmod them 755.

Can anyone give me a good example for doing this? So far all I've found is:


$source_file = '/tmp/file.html';
$dest_file = '/home/mydomain/file.html';
copy($source_file, $dest_file);



thanks in advance
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

What happens when you chmod it to 766 ?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Check out the function chmod() and explore around the PHP manual's filesystem section.

Keep an eye on the user notes because often they can be very helpful for beginners in a specific part of PHP scripting.
Post Reply