This is the scenario.

I have a defaultimage in an 'images' folder.

When someone registers it creates a directory like so:


Each time someone registers i want also the defualtimage to be copied to the new users directory, so they then have an image to start off with.



To copy an image from one folder to another, you'll have to read from the image file that you would like to copy, then create another file preferably with the same name as the original file in the directory to which you would like to copy it into. here is php code to illustrate this.

//I don't know what the name of your main directory is but i'll assume for this //example it is users
//Now your default image is in an images directory.....

//The code
$img = default_image.png; //name of file to be copied
//read the file
$fp = fopen('images/'.$img3, 'r') or die("Could not contact $img3");
$page_contents = "";
while ($new_text = fread($fp, 100)) 
$page_contents .= $new_text;

chdir($new_userid."/images"); //This moves you from the current directory user to the images directory in the new user's directory

$newfile = "default_image.png"; //name of your new file
//create new file and write what you read from old file into it
$fd = fopen($newfile, 'w');
fwrite($fd, $page_contents);
fclose ($fd);//close the file
Member Avatar


If you want it copied use the copy() command.
If you want the file moved, use rename() command.

Check the manual for usage - it's very simple.

just know i found very gud info