1function grab_image($url,$saveto){
2 $ch = curl_init ($url);
3 curl_setopt($ch, CURLOPT_HEADER, 0);
4 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
5 curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
6 $raw=curl_exec($ch);
7 curl_close ($ch);
8 if(file_exists($saveto)){
9 unlink($saveto);
10 }
11 $fp = fopen($saveto,'x');
12 fwrite($fp, $raw);
13 fclose($fp);
14}