Hi All,
Trying to get a file from a remote server. fopen and fsockopen were troublesome so I thought I'd try cURL. Have never used it though
So I built this function
and am getting this error. I am sure I've done something silly...
error:
Any advice would be appreciated.
TIA
Bastien
Cat, the other other white meat
Trying to get a file from a remote server. fopen and fsockopen were troublesome so I thought I'd try cURL. Have never used it though

So I built this function
Code:
function get_file1($file, $local_path, $newfilename)
{
$err_msg = '';
echo "<br>Attempting message download<br>";
echo "File: fopen($file, 'r')<br>";
if (!$handle = fopen($newfilename, 'w')){
$err_msg = "File not opened<br>";
}
list($site, $uri) = explode("/",$file);
$ch = curl_init($site);
$handle2 = fopen($uri, "r");
curl_setopt($ch, CURLOPT_FILE, $handle2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
if ($handle){
if (fwrite($handle,$data) === FALSE){
$err_msg .= "Unable to write to file<br>";
}
}
curl_close($ch);
fclose($handle2);
if ($handle){ fclose($handle); }
if ($handle2){ fclose($handle2);}
}//end function
and am getting this error. I am sure I've done something silly...

error:
Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in C:\Apache2\ on line 383
Any advice would be appreciated.
TIA
Bastien
Cat, the other other white meat