当我尝试从服务器
下载某些文件时,我有以下代码超时<?php
$ch = curl_init();
$source=array("landshop_formdata.sql","landshop_clientdata.sql","landshop_blogs.sql","landshop_counter.sql","landshop_hitems.sql");
$sourcepath = "http://www.landshoppe.com/";
$root = "C:\Program Files\EasyPHP-5.3.8.1\www\Landshoppe/Downloaded Dbs/";
foreach($source as $bkup){
$source=$sourcepath.$bkup;
curl_setopt($ch, CURLOPT_URL, $source);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec ($ch);
$destination = $root.$bkup;
$data = file_get_contents($source);
$file = fopen($destination, "w+");
fputs($file, $data);
fclose($file);
}
?>
应该是什么问题?
答案 0 :(得分:1)
为避免超时问题,您可以通过在服务器端代码顶部添加此行来禁用它:
set_time_limit(0); // no time limit
或者,您可以设置足够长的超时时间,以便在没有任何事情发生时通知您的用户出现问题。