我正在使用以下代码从URL打开CSV文件:
$data=fopen('http://url.ro/file','r');
$x = 0;
while (($line = fgetcsv($data)) !== FALSE) {
print_r($line);
$x++;
if($x >= 5){
exit('exit');
}
}
这在localhost上工作正常,但是当我将其移至服务器时出现此错误:
PHP Warning: fgetcsv() expects parameter 1 to be resource, boolean given
P.S:我从url中获取文件内容(如果我直接访问该URL,它将下载csv文件)