did you want something like this ?
function get_file($file, $local_path, $newfilename)
{
$err_msg = '';
echo "<br>Attempting message download for $file<br>";
$out = fopen($local_path.$newfilename,"wb");
if ($out == FALSE){
print "File not opened<br>";
exit;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $out);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $file);
curl_exec($ch);
echo "<br>Error is : ".curl_error ( $ch);
curl_close($ch);
//fclose($handle);
}//end function
Functionality:
Its a function and accepts three parameters
get_file($file, $local_path, $newfilename)
$file
: is the filename of the object to be retrieved
$local_path
: is the local path to the directory to store the object
$newfilename
: is the new file name on the local system
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…