'Utf-8'/> PHP//define the directory you want to view$dir ="/"; //determine if $_get[' a '] has passed the value to prevent notice errors if(Isset ($_get['a'])){ //choose to decide what action to take Switch($_get['a']){ Case 'creat': //New File$filename =$_post["filename"]; $filename=rtrim ($dir,"/")."/". $filename; //write to file write an empty stringFile_put_contents ($filename,""); Break; Case 'del': //Deleting FilesUnlink ($_get['filename']); Break; Case 'Update': //Modify a fileFile_put_contents ($_post['filename'],$_post['content']); Echo"Modification succeeded"; Header ("refresh:1;url=index.php"); Break; } } ?> <center> 'index.php?a=creat'Method='Post'>File:<input type='text'Name='filename'/> <input type='Submit'Value='New'/> </form> <table border='1'Width=' the'cellpadding='5'cellspacing='0'> <tr> <th> file name </th> <th> type </th> <th> size </th> <th> creation time </th> <th> action </th > </tr> <?PHP//Traverse Directory$DD =Opendir ($dir); while(false!== ($f =Readdir ($DD))) { //Filter Point if($f = ="."|| $f = =".."){ Continue; } //Spell Path$file =rtrim ($dir,"/")."/". $f; //prevent Chinese garbled characters$f 2=iconv ("gb2312","Utf-8", $f); Echo"<tr>"; Echo"<td>{$f 2}</td>"; Echo"<td>". FileType ($file)."</td>"; Echo"<td>". FileSize ($file)."</td>"; Echo"<td>". Filectime ($file)."</td>"; Echo"<td align= ' center ' ><a href='index.php?a=edit&filename={$file}'> Modify </a>| <a href='index.php?a=del&filename={$file}'> Delete </a> </td>";Echo"</tr>"; } ?> </table> <?PHPif(Isset ($_get['a']) && $_get['a']=='Edit') {echo""; Echo"<form action= ' index.php?a=update ' method= ' post ' >"; Echo"file name: <input type= ' text ' name= ' filename ' readonly value= ' {$_get[' filename '} '/>"; Echo"<br/><br/>"; Echo"<textarea name= ' content ' rows= ' 5 ' cols= ' >". file_get_contents ($_get['filename'])."</textarea>"; Echo"<br/><br/>"; Echo"<input type= ' Submit ' value= ' Save changes '/>"; Echo"</form>"; } ?> </center> </body>PHP Simple File Manager--php Classic Instance
PHP Simple File Manager--php Classic Instance