雖然是老問題了,但是看了網(wǎng)友的解答我還是不明白,求解釋!
兩個(gè)問題: ①始終顯示act 和 filename未定義②創(chuàng)建1.txt 也沒有echo 出來$path."--" 和$filename
我采取的措施以及發(fā)現(xiàn)的問題:
我已經(jīng)嘗試了像老師說的那樣修改php.ini配置error_reporting,結(jié)果還是一樣,沒有作用
我發(fā)現(xiàn)下載的源代碼和老師課堂上寫的代碼有些不一樣,懷疑是不是因?yàn)閚ame和value的值造成的下面附上老師上課的“課堂代碼"和下載的“源代碼”
實(shí)在不解,還求解釋啊~
2015-10-20
哥們,需要在table外面套上form標(biāo)簽才行,<form action="index.php" method="post" enctype="multipart/form-data"></form>
2015-08-09
再附上小弟自己的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=="創(chuàng)建文件"){
//創(chuàng)建文件
//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>慕課網(wǎng)-在線文件管理器</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="返回上級(jí)目錄"><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>請(qǐng)輸入文件夾名稱</td>
<td >
<input type="text" name="dirname" />
<input type="submit" ?name="act" ?value="創(chuàng)建文件夾"/>
</td>
</tr>
<tr id="createFile" ?style="display:none;">
<td>請(qǐng)輸入文件名稱</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="創(chuàng)建文件" />
</td>
</tr>
<tr id="uploadFile" style="display:none;">
<td >請(qǐng)選擇要上傳的文件</td>
<td ><input type="file" name="myFile" />
<input type="submit" name="act" value="上傳文件" />
</td>
</tr>
<tr>
<td>編號(hào)</td>
<td>名稱</td>
<td>類型</td>
<td>大小</td>
<td>可讀</td>
<td>可寫</td>
<td>可執(zhí)行</td>
<td>創(chuàng)建時(shí)間</td>
<td>修改時(shí)間</td>
<td>訪問時(shí)間</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="復(fù)制"/></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>