Error:
Warning: readdir(): supplied argument is not a valid Directory resource
Hi,
Can you please tell me whats wrong with this code.
It gives me above error.
I iam trying to list files on the server and menaged them, ( delete, move etc)
The directory is CHMOD to 777.
Can you give me a better method to do this ?
Thanks?
Here is the code :
require_once("../classes/auth_class.php");
require_once("../classes/utill_class.php");
include("../classes/clsCheck_$language.php");
require_once(HEADERF);
$path=$path_upload;
$handle=opendir($path);
$dir_size=0;
while ($file = readdir($handle)){
if($file != "." && $file != ".." ){
$dir_size+=filesize($path."/".$file);
}
}
if(IsSet($message)){
$ns -> tablerender("", "<div style=\"text-align:center\"><b>".$message."</b></div>");
}
if(isset($delete)){
foreach ($f_name as $ff_name){
@unlink( $path."/".$ff_name);
}
}
$text .= "<form method=\"post\" action=\"$PHP_SELF\" id=\"frm_add\" name=\"frm_add\">
<table style=\"width:95%\">";
$handle=opendir($path);
while ($file = readdir($handle)){
if($file != "." && $file != ".." ){
$file_extention = strtolower(substr(strrchr($file, "."), 1));
$file_name=substr($file,0, strrpos($file, "."));
$text .= "<tr><td>
<input name=\"f_name[]\" value=\"$file\" type=\"checkbox\" class=\"tbox\" ></td><td>
<a href=\"_view_files.php?nFile=".$file."\" target=\"_blank\">".$file."</a>
<a href=\"user.php?searchquery=".$file_name."&searchsubmit=1\" target=\"_blank\">".LAN_4."</a>
</td></tr>";
}
}
$text .= "
</td>
</tr>
<tr style=\"vertical-align:top\">
<td style=\"width:20%\" ></td>
<td style=\"width:80%\">
<input class=\"button\" type=\"submit\" name=\"delete\" value=\"".LAN_DELETE."\" />
</td>
</tr>
</table>
</form>";
$ns -> tablerender("<div style=\"text-align:center\">".LAN_201."</div>", $text);
require_once(FOOTERF);