範例一
copy('http://l.yimg.com/f/a/tw/momo/20120223_350x200_8305470229_T.jpg', $_SERVER['DOCUMENT_ROOT'].'/test/flower.jpg');
範例二(智邦可用)
<?php
function download_remote_file_with_curl($file_url, $save_to)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch,CURLOPT_URL,$file_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$file_content = curl_exec($ch);
curl_close($ch);
$downloaded_file = fopen($save_to, 'w');
fwrite($downloaded_file, $file_content);
fclose($downloaded_file);
}
download_remote_file_with_curl('http://l.yimg.com/f/a/tw/momo/20120223_350x200_8305470229_T.jpg', $_SERVER['DOCUMENT_ROOT'].'/test/flower.jpg');
?>
全站熱搜