I want to make a simple copy using ajax call. this is my code but it does not work. I kepp getting: copy (../../images/merchant/specifics/208/) could not open the stream: Is the directory in some / filepath on scriptname.php line x, kind of error.
corrected code: $dir_to_make = '../../images/merchant/particulars/'.$copytothisstore; $dir = '../../images/merchant/particulars/'.$copytothisstore.' /'.$copyvalue; $image_to_copy = '../../images/merchant/particulars/'.$copyfromthisstore.'/'.$copyvalue; if(is_file($image_to_copy)){ //chk if there is a folder created for this store if(!is_dir($dir_to_make)){ mkdir($dir_to_make, 0755); chmod($dir_to_make, 0755); //copy the image if (!copy($image_to_copy,$dir)) { echo "failed to copy $image_to_copy\n"; } else { echo"all is well!!"; } } else { chmod($dir_to_make, 0755); if (!copy($image_to_copy,$dir)) { echo "failed to copy $image_to_copy\n"; } else { echo"all is well!!"; } } echo"$image_to_copy does exist!"; } else{ echo"$image_to_copy does not exist!"; }
source share