PHP Guru - need ur help
I want to "Download' a file from a remote server with a PHP script.
I used this function below, but I need to enable the remote file opening option in php.ini to make it work. Let's say that I can't turn on this option for some reason. What else can I do to avoid this problem ? Is FTP functions my answer ?
Thanks
function download($file_source , $file_target) {
$rh = fopen ($file_source, 'rb');
$wh = fopen($file_target, 'wb' );
if ($rh===false || $wh=== false) {
return true;
}
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;
}
__________________
I have nothing to advertise ... yet.
|