如何让PHP从C:驱动器读取csv文件

时间:2013-02-20 12:55:25

标签: php file-io

我想使用PHP从Windows C:驱动器C:\downloads读取CSV(逗号分隔值)文件。

这是我到目前为止的代码:

<?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文件?

0 个答案:

没有答案