0

There is a big iso file on the web from which i want to write it into my local directory with CURLOPT_BUFFERSIZE as 102400 bytes,so i wrote the following code to do the 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 are some bugs in it,but no error ouput,i can't download the target iso file,how to fix it?

showkey
  • 482
  • 42
  • 140
  • 295

1 Answers1

0

Try to set TIMEOUT and CONNECTTIMEOUT options. Try to debug you code using var_dump($str); and

curl_error($ch);

Reading of How to partially download a remote file with cURL? might be useful.

Community
  • 1
  • 1
Taras Soroka
  • 126
  • 7
  • I mean CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT options, max_execution_time=0 set unlimited execution time of entire script only. – Taras Soroka May 31 '15 at 15:16