两个问题: ①始终显示act 和 filename未定义②创建1.txt 也没有echo 出来$path."--" 和$filename
我采取的措施以及发现的问题:
我已经尝试了像老师说的那样修改php.ini配置error_reporting,结果还是一样,没有作用
我发现下载的源代码和老师课堂上写的代码有些不一样,怀疑是不是因为name和value的值造成的下面附上老师上课的“课堂代码"和下载的“源代码”
实在不解,还求解释啊~哥们,需要在table外面套上form标签才行,<form action="index.php" method="post" enctype="multipart/form-data"></form>
再附上小弟自己的index.php代码:
<?php
require("dir.func.php");
require("file.func.php");
//require("common.func.php");
$path = "file";
$act = $_REQUEST['act'];
$filename = $_REQUEST['filename'];
$info =readDirectory($path);
//print_r($info);
//$redirect="index.php?path={$path}";
if($act=="创建文件"){
//创建文件
//echo $path."--";
//echo $filename;
//$mes = createFile($path."/".$filename);
//alertMes($mes,$redirect);
echo $path."--";
echo $filename;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>insert title here</title>
<link rel="stylesheet" href="cikonss.css" />
<style type="text/css">
body,p,div,ul,ol,table,dl,dd,dt{
margin: 0px;
padding: 0px;
}
a{
text-decoration: none;
}
ul li {
list-style: none;
float: left;
}
#top{
width:100%;
height:48px;
margin:0 auto;
background: #E2E2E2;
}
.small{
width:25px;
height:25px;
border:0;
}
#navi a{
display: block;
width:48px;
height: 48px;
}
</style>
<script type="text/javascript">
function show(dis){
document.getElementById(dis).style.display="block";
}
</script>
</head>
<body>
<h1>慕课网-在线文件管理器</h1>
<div id="top">
<ul id="navi">
<li><a href="index.php" title="主目录"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-home"></span></span></a></li>
<li><a href="#" onclick="show('createFile')" title="新建文件"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-file"></span></span></a></li>
<li><a href="#" onclick="show('createFolder')" title="新建文件夹"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-folder"></span></span></a></li>
<li><a href="#" onclick="show('uploadFile')" title="上传文件"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-upload"></span></span></a></li>
<li><a href="#" title="返回上级目录"><span style="margin-left: 8px; margin-top: 0px; top: 4px;" class="icon icon-small icon-square"><span class="icon-arrowLeft"></span></span></a></li>
</ul>
</div>
<table width="100%" border="1" cellpadding="5" cellspacing="0" bgcolor="#ABCDEF" align="center">
<tr id="createFolder" style="display:none;">
<td>请输入文件夹名称</td>
<td >
<input type="text" name="dirname" />
<input type="submit" name="act" value="创建文件夹"/>
</td>
</tr>
<tr id="createFile" style="display:none;">
<td>请输入文件名称</td>
<td >
<input type="text" name="filename" />
<input type="hidden" name="path" value="<?php echo $path;?>"/>
<input type="hidden" name="act" value="createFile"/>
<input type="submit" value="创建文件" />
</td>
</tr>
<tr id="uploadFile" style="display:none;">
<td >请选择要上传的文件</td>
<td ><input type="file" name="myFile" />
<input type="submit" name="act" value="上传文件" />
</td>
</tr>
<tr>
<td>编号</td>
<td>名称</td>
<td>类型</td>
<td>大小</td>
<td>可读</td>
<td>可写</td>
<td>可执行</td>
<td>创建时间</td>
<td>修改时间</td>
<td>访问时间</td>
<td>操作</td>
</tr>
<?php
$i=1;
if($info['file']){
foreach ($info['file'] as $val) {
$p = $path.'/'.$val;
?>
<tr>
<td><?php echo $i;?></td>
<td><?php echo $val;?></td>
<td><?php $src=filetype($p)=="file"? "file_ico.png" : "folder_ico.png"?><img src="images/<?php echo $src;?>" alt="" title="文件"></td>
<td><?php echo transByte(filesize($p))?></td>
<td><?php $src=is_readable($p)==true?"correct.png":"error.png"; ?><img class="small" src="images/<?php echo $src; ?>"</td>
<td><?php $src=is_writeable($p)==true?"correct.png":"error.png"; ?><img class="small" src="images/<?php echo $src; ?>"</td>
<td><?php $src=is_executable($p)==true?"correct.png":"error.png"; ?><img class="small" src="images/<?php echo $src; ?>"</td>
<td><?php echo date("Y-m-d H:i:s",filectime($p));?></td>
<td><?php echo date("Y-m-d H:i:s",filemtime($p));?></td>
<td><?php echo date("Y-m-d H:i:s",fileatime($p));?></td>
<td>
<!--<a href="#" onclick="showDetail('<?php echo $val;?>','<?php echo $p;?>')"><img class="small" src="images/show.png" alt="" title="查看"/></a>|-->
<a href="index.php?act=showContent&path=<?php echo $path;?>&filename=<?php echo $p;?>" ><img class="small" src="images/show.png" alt="" title="查看"/></a>|
<a href="index.php?act=editContent&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/edit.png" alt="" title="修改"/></a>|
<a href="index.php?act=renameFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/rename.png" alt="" title="重命名"/></a>|
<a href="index.php?act=copyFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/copy.png" alt="" title="复制"/></a>|
<a href="index.php?act=cutFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/cut.png" alt="" title="剪切"/></a>|
<a href="#" onclick="delFile('<?php echo $p;?>','<?php echo $path;?>')"><img class="small" src="images/delete.png" alt="" title="删除"/></a>|
<a href="index.php?act=downFile&path=<?php echo $path;?>&filename=<?php echo $p;?>"><img class="small" src="images/download.png" alt="" title="下载"/></a>
</td>
</tr>
<?php
$i++;
}
}
?>
</table>
</body>
</html>