php - Write big file from web into local directory with CURLOPT_BUFFERSIZE -
there big iso file on web want write local directory curlopt_buffersize 102400 bytes,so wrote following code job.
<?php $url="http://gensho.acc.umu.se/debian-cd/8.0.0/i386/iso-cd/debian-8.0.0-i386-lxde-cd-1.iso"; $ch=curl_init(); $a_opt=array( curlopt_url => $url, curlopt_header => 0, curlopt_returntransfer => 1, curlopt_binarytransfer => 1, curlopt_buffersize => 102400 ); curl_setopt_array($ch,$a_opt); $str=curl_exec($ch); $f=fopen('/tmp/debian.iso','w'); fwrite($f,$str) ?>
maybe there bugs in it,but no error ouput,i can't download target iso file,how fix it?
try set timeout , connecttimeout options. try debug code using var_dump($str)
; and
curl_error($ch);
reading of how partially download remote file curl? might useful.
Comments
Post a Comment