Using the file-related functions in PHP to manage a folder on the server, you can make simple file view and delete files and folders, add operations.
First, traverse the folder:
$fname = "Folder Path", while ($n = Readdir ($dir)) //Traverse all files and folders in the folder {$url = $fname. " /". $n; if ($n! =". "&& $n! =" ... ") {if (Is_dir ($url)) {echo "<div class= ' file Mulu ' lj= ' {$url} ' >{$n}</div>"; If the folder displays a special color}else{echo "<div class= ' file ' lj= ' {$url} ' >{$n} <input type= ' button ' value= ' delete ' lj= ' {$url} ' class= ' sc '/> </div> ";}}} Closedir ($dir);
Add the Create File button:
<input type= "text" id= "name"/><input type= "button" value= "new" id= "Newf"/>
Add a simple style:
CSS code:
*{margin:0px Auto; padding:0px}.file{width:50%; height:35px; line-height:35px; vertical-align:middle; border:1px Solid #63C; margin-top:2px;}. mulu{background-color: #63C; color:white}.prev{background-color: #F63; Color:white}
To add a click event, click on the folder to go to the next directory:
To introduce the JQ package:
$ (". Mulu"). DblClick (function () {var url = $ (this). attr ("LJ"); $.ajax ({url: "chuli.php", Data:{url:url},type: "POST", DataType: "TEXT", success:function (data) {window.location.href = "test.php";}})
Processing interface (chuli.php):
<?phpsession_start (); $url = $_post["url"];$_session["url"] = $url;
To add a Delete event:
$ (". SC"). Click (function () {var LJ = $ (this). attr ("LJ"); $.ajax ({url: "shanchu.php", Data:{lj:lj},type: "POST", DataType : "TEXT", success:function (data) {window.location.href = "test.php";}})
Processing interface (shanchu.php):
<?PHP$LJ = $_post["LJ"];unlink ($LJ);
To add a new file event:
$ ("#newf"). Click (function () {var name = $ ("#name"). Val (); $.ajax ({url: "xinjian.php", Data:{name:name},type: "POST", DataType: "TEXT", success:function (data) {window.location.href = "test.php";}})
Background processing interface: (xinjian.php):
<?phpsession_start (); $name = $_post["name"]; $url = $_session["url"]; $filename = $url. " /". $name; Touch ($filename);
At this point, the basic implementation of the function, but click on the folder into the next interface can not be returned, so to add the return button:
$JDLJ = Realpath ($fname), if ($JDLJ = = "d:\\wamp\\www\\1027") {}else{$fuji = dirname ($fname); echo "<div class=" file Prev ' lj= ' {$fuji} ' > Return to previous </div> ';}
$ (". Prev"). DblClick (function () {var url = $ (this). attr ("LJ"); $.ajax ({url: "chuli.php", Data:{url:url},type: "POST", DataType: "TEXT", success:function (data) {window.location.href = "test.php";}})
So click on the folder to return:
All code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
Network Disk File Management