[SOLVED]...cURL help please...
Posted: Thu Sep 16, 2004 11:00 am
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:
TIA
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: Select all
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 functionerror:
Any advice would be appreciated.Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in C:\Apache2\WWW\localhost\email\custom_pop3.php on line 383
TIA