我想使用 PHP 从 WindowsC:
驱动器中读取 CSV(逗号分隔值)文件C:\downloads
。
这是我到目前为止的代码:
<?php
$file = "c:\\downloads\\test.csv";
$f = fopen($file, "r");
while ($record = fgetcsv($f)) {
foreach($record as $field) {
echo $field . "<br>";
}
}
fclose($f);
?>
但是,我收到以下警告:
Warning: fopen(c:\downloads\test.csv) [function.fopen]: failed to open stream:
No such file or directory in /home/content/99/10187599/html/csvread.php on line 3
Warning: fgetcsv() expects parameter 1 to be resource, boolean given
in /home/content/99/10187599/html/csvread.php on line 4
Warning: fclose() expects parameter 1 to be resource, boolean given in
/home/content/99/10187599/html/csvread.php on line 9
我从http://phpmaster.com关注这个例子。
如何在 PHP 中从本地磁盘读取 csv 文件?