请各位高手帮忙~~有关php的~~

来源:百度知道 编辑:UC知道 时间:2024/06/17 03:36:43
<html>
<head>
<title> 我的文件查看器</title>
</head>
<body>
<a href="./file_viewer1.php">返回文件管理器</a><br><br>
<?

$currentdir=$_get[currentdir];
$filename=$_get[filename];
$type=$_get[type];
if($type==".php")
{
readfile($currentdir."\\".$filename);

}
else
{
$fp=fopen($currentdir."\\".$filename,"r");
while($line=fgets($fp))
{

$line=htmlentities($line,ENT_COMPAT,"GB2312");
echo $line;
}
fclose($fp);
}

?>
</body>
</html>

这段php代码执行后总是要显示这三个warming:

Warning: fopen(\) [function.fopen]: failed to open stream: No such file or directory in F:\php\AppS

readfile($currentdir."\\".$filename);
只有一个原因,这里的文件名不存在。
建议这样 $currentdir."/".$filename

这个警告是说找不到F:\php\AppServ\www\show_file2.php这个文件,检查一下看看这个文件存在不.

建议你不要用“\\”这是WINDAOWS的目录习惯
最好是用“/”

$currentdir."\\".$filename 目录不存在 你确定你确实有那个文件吗