clearstscache()没有清除文件信息PHP

时间:2013-11-24 18:57:10

标签: php

我正在使用php编写一个简化的在线文件存储实用程序,并且在尝试列出目录中的文件时遇到了clearstatcache()的问题。

<?php
  $dir = dir("../archive");
  echo "<label for=\"Display Contents\" style=\"float:left;\">Contents of Archive
  </label><div style=\"clear:both;\"></div><br/>";

  //LIST FILES IN PARENT FOLDER
  while (($file = $dir->read()) !== false){
    echo "<li>Filename: <a href=\"../archive/" . $file . "\" target=\"_blank\">" . 
      $file . "</a> &nbsp; &nbsp; 
      <span style=\"float:right;\">
      File Type: " . filetype($file) . " &nbsp; 
      File Size:" . filesize($file) . "</span>
      <div style=\"clear:both;\"></div><hr/>
    <form action=\"remove.php\" method=\"post\">
      <input type=\"checkbox\" name=\"delete\" id=\"delete\" value=\"" .$file . "\">
      Delete this file <button type=\"submit\" value=\"Submit\">
      Delete</button></form> &nbsp; | &nbsp; 
    <form action=\"send.php\" method=\"post\">
      <input type=\"checkbox\" name=\"send\" id=\"send\" value=\"" .$file . "\"> 
      Email this file <button type=\"submit\" value=\"Submit\">
      Send</button></form>";
    clearstatcache($file);
} $dir->close();
?>

以下显示我的内容,直到目录中的第一个文件类型更改为止,这给了我一个错误:

“警告:filetype()[function.filetype]:第15行的C:\ xampp \ htdocs \ archiver \ includes \ list.php中的20130927-full.csv的Lstat失败

警告:filesize()[function.filesize]:第15行的C:\ xampp \ htdocs \ archiver \ includes \ list.php中的20130927-full.csv的stat失败“

第15行是调用filetype和filesize。我不确定我是否正在使用clearstatcache不正确,如果它应该被调用函数的每次迭代,在函数之外,或者如果我可能需要考虑不同的方法。任何想法都将不胜感激。

0 个答案:

没有答案