Is there any reason the following code would work when accessed via browser but not via cron? Sorry for the commented code ... all of the methods produce the same result.
$toEncode = substr($img_url, strrpos($img_url, '/')+1);
#echo $toEncode.'<br />';
$url = substr($img_url, 0, strrpos($img_url, '/')+1);
#echo $url.'<br />';
$encoded = rawurlencode($toEncode);
$img_url = $url . $encoded;
#echo $img_url.'<br />';
$img = file_get_contents($img_url, FILE_BINARY, NULL, 0, 1024000);
#$h = fopen($img_url, "rb");
#$img = fread($h, 102400);
#fclose($h);
#$curl = curl_init($img_url);
#curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
#$img = curl_exec($curl);
$file_name = str_replace(array(" ", '(', ')', '+', '!'), '_', rawurldecode($encoded));
#echo $file_name.'<br />';
#header('Content-type: image/jpeg');
#echo $img;
file_put_contents(LISTING_IMAGES_DIR.$file_name, $img);
TIA!