php实现的遍历文件夹下所有文件,编辑删除
|
<div class="codetitle"><a style="CURSOR: pointer" data="8021" class="copybut" id="copybut8021" onclick="doCopy('code8021')"> 代码如下:<div class="codebody" id="code8021"> 编辑文件> <a href="'.$url.'">返回</td></tr> <tr> <td height="25" align="left" bgcolor="#FFFFCC">->文件名:'.$_GET['path'].'</td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><textarea name="textarea" cols="135" rows="20">'.$result.'</td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td> </tr> </table> '; }else{ echo '<form name="form1" method="post" action="?action=dir_rename&path='.$_GET['path'].'&type='.$_GET['type'].'"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td height="25" bgcolor="#99CC00">>> 新建文件> <a href="'.$url.'">返回</td></tr> <tr> <td height="25" align="left" bgcolor="#FFFFCC">->文件夹更名: <input name="filename" type="text" value="'.$_GET['path'].'" size="50"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td> </tr> </table> '; } break; case "editsave"; $file=fopen($_GET['path'],"w"); fwrite($file,$_POST['textarea']); fclose($file); echo "<script type="text/javascript">alert('恭喜,编辑成功!');location.href="".$url."";"; break; case "addfile"; echo '<form name="form1" method="post" action="?action=filesave&path='.$_GET['path'].'"> <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td height="25" bgcolor="#99CC00">>> 新建文件> <a href="'.$url.'">返回</td></tr> <tr> <td height="25" align="left" bgcolor="#FFFFCC">->文件名: <input name="filename" type="text" value="'.$_GET['path'].'" size="50"></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><textarea name="textarea" cols="135" rows="20">输入内容 </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td> </tr> </table> '; break; case "filesave"; //包含点则建立文件,否则建立文件夹 if(strpos($_POST['filename'],".")) { $file=fopen($_POST['filename'],$_POST['textarea']); fclose($file); }else{ //文件夹若存在则退出,不存在则建立! if(file_exists($_POST['filename'])) { exit; }else{ mkdir($_POST['filename']); } } echo "<script type="text/javascript">alert('恭喜,".$_POST['filename']."建立成功!');location.href="".$url."";"; break; case "dir_rename"; rename($_GET['path'],$_POST['filename']); echo "<script type="text/javascript">alert('恭喜,".$_POST['filename']."改名成功!');location.href="".$url."";"; break; default: $s=explode("n",trim( dir/b/o:gn $path)); echo '<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td height="25" colspan="4" bgcolor="#99CC00">>> 文件管理> <a href="?action=addfile&path='.$path.'">建立文件 > <a href="'.$url.'">返回</td></tr> <tr> <td height="25" align="center" bgcolor="#FFFFCC">文件/文件夹</td> <td align="center" bgcolor="#FFFFCC">文件属性</td> <td align="center" bgcolor="#FFFFCC">文件大小</td> <td align="center" bgcolor="#FFFFCC">操作</td> </tr>'; foreach($s as $value) { echo ' <tr> <td height="25" bgcolor="#FFFFFF">'.folder($path,$value).'</td> <td align="center" bgcolor="#FFFFFF">'.filetype($path.$value).'</td> <td align="right" bgcolor="#FFFFFF">'.round(filesize($path.$value)/1024).'kb</td> <td align="center" bgcolor="#FFFFFF"><a href="?action=edit&path='.$path.''.$value.'&type='.filetype($path.$value).'">编辑 | <a href="?action=del&path='.$path.''.$value.'&type='.filetype($path.$value).'" onClick="return confirm('确定删除->'.$value.'');">删除</td> </tr>'; } echo "</table>"; break; } ?> (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
