【问题标题】:Using WAMP: Read file permissions on Windows使用 WAMP:在 Windows 上读取文件权限
【发布时间】:2012-01-08 17:20:36
【问题描述】:

我的系统:windos xp

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

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

为什么会发生这种情况,原因我无法确定。

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

代码

$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;

【问题讨论】:

  • 尝试以管理员身份启动 wamp 服务器
  • 首先尝试找出错误信息是什么。
  • 没有错误,没有通知,没有警告。只显示文件大小而不是内容。
  • 请发布实际解析的代码...

标签: php windows-xp


【解决方案1】:

你的问题是:

  • eturn 应该是 return - 这可能是一个解析错误
  • 实际问题是您调用fgetc($fileName) 而应该是fgetc($fp)。您将文件名的字符串传递给fgetc(),而不是您创建的文件指针。

变化:

$fileData .= fgetc($fileName);

$filedata .= fgetc($fp);

【讨论】:

    猜你喜欢
    • 2010-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-21
    • 2018-09-21
    • 2011-05-27
    • 2015-11-10
    • 2011-03-12
    相关资源
    最近更新 更多