Grabbing image with cURL php -
trying save image server using curl. image appears download. shows correct bytes when link image not work. dl see , nope blank image.
here code... whats issue it?
$ch = curl_init("'. $image .'"); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_binarytransfer,1); $rawdata=curl_exec ($ch); curl_close ($ch); $fp = fopen("$rename.jpg",'w'); fwrite($fp, $rawdata); fclose($fp);
i test script work fine me, remove useless double quote , dot $image.
<? $image ="http://cdn.sstatic.net/stackoverflow/img/sprites.png?v=5"; $rename="123"; $ch = curl_init($image); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_binarytransfer,1); $rawdata=curl_exec ($ch); curl_close ($ch); $fp = fopen("$rename.jpg",'w'); fwrite($fp, $rawdata); fclose($fp); ?>
Comments
Post a Comment