2012-01-08 66 views
0

我的系统:windos xp使用WAMP:在Windows上读取文件权限

我已将所有用户权限授予文件。

,但我无法读取文件,但我得到的文件大小,

为什么这样的事情发生,原因,我无法确定。

我该怎么办才能解决这个问题。

代码

$fileName = "1.php"; 

if (floatval(phpversion()) >= 4.3) { 

    //loading data 
    $fileData = file_get_contents($fileName); 
    print(filesize($fileName)); 

} else { 

    //if file not exist then return -3 
    if (!file_exists($fileName)) { 
    eturn -3; 
    } 

    $fp = fopen($fileName, 'r'); 
    // if file is not open in read mode then return -2 
    if (!$fp) return -2; 

    $fileData = ''; 
    print(filesize($fileName)); 

    //checking end of file 
    while(!feof($fp)) 
    $fileData .= fgetc($fileName); 

    fclose($fp); 

} 

echo $fileData; 
+0

尝试启动WAMP的服务器管理员 – Parzifal 2012-01-08 17:21:26

+0

首先的尝试找出错误信息是什么。 – hakre 2012-01-08 17:25:50

+0

在这里分享一些代码 – 2012-01-08 17:27:12

回答

0

你的问题是:

  • eturn应该说return - 这可能是一个语法错误
  • 实际问题是,你在呼唤fgetc($fileName)当它应该是fgetc($fp)。您将文件名的字符串传递给fgetc()而不是您创建的文件指针。

变化:

$fileData .= fgetc($fileName); 

$filedata .= fgetc($fp);