FWIW, I used the following script from php.net for fopen (for future searches):
$rh = fopen($source_file, 'r');
$wh = fopen($target_file, 'w+');
if ($rh===false || $wh===false) {
return true;
} // error reading or opening file
while (!feof($rh)) {
if (fwrite($wh, fread($rh, 1024)) === FALSE) {
// 'Download error: Cannot write to file ('.$file_target.')';
return true;
}
}
fclose($rh);
fclose($wh);
// No error
return false;