I want to copy selected image file one folder into another folder. Image selection process is dynamically. i am using below php code for copy process.
//$cnt is count of selected images
for($i=0;$i<$cnt;$i++)
{
$img = $sel['album_images']; //name of file to be copied
//read the file
$fp = fopen('uploads/members/album/'.$_SESSION['ses_userid'].'/'.$img, 'r') or die("Could not contact $img");
$page_contents = "";
while ($new_text = fread($fp, 100))
{
$page_contents .= $new_text;
}
chdir("uploads/products/design/"); //This moves you from the current directory user to the images directory in the new user's directory
$newfile = "product-".strtotime('now').".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);
}
The above code is run perfectly for if the selected image count is 1.but it produce the error if the selected image count above 1.
Error is :
Warning: fopen(uploads/members/album/72/full_e5829jellyfish.jpg) [function.fopen]: failed to open stream: No such file or directory in D:\wamp\www\myprint\photoprint_step2.php on line 51
Could not contact full_e5829jellyfish.jpg
Note : If the selected image count is 2 then the first image will be copied successfully , next (2nd image) the error will be produced. What happened?