PHP traverses all files under the specified folder, as follows:
- <?php
- Session_Start ();
- if ($Submit = = "Submit") {
- $shili = $file _dir;
- }
- ?>
- <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
- <title> traverse all files in the specified directory-www.cxybl.com</title>
- <body>
- <table width= "height=" border= "0" cellpadding= "0" cellspacing= "0" background= "images/324.jpg" >
- <form name= "Form1" method= "Post" action= "index.php" >
- <tr>
- <TD width= "132" height= "> </td>"
- <TD width= "135" > </td>
- <TD width= "> </td>"
- </tr>
- <tr>
- <TD height= > </td>
- <TD align= "center" >
- <input name= "File_dir" type= "text" id= "File_dir" size= "a" maxlength= "M" ></td>
- <td> <input type= "Submit" name= "Submission" value= "submitted" ></td>
- </tr>
- <tr>
- <TD height= "> </td>"
- <td> </td>
- <td> </td>
- </tr>
- </form>
- </table>
- <?php
- $shili = $file _dir;
- if (!file_exists ($shili)) {
- Print $shili. " Directory does not exist! ";
- }else{
- $i = 0;
- if (Is_dir ($shili)) {//detect whether it is a legal directory
- if ($shi = Opendir ($shili)) {//Open Directory
- while ($li = Readdir ($shi)) {//Read directory
- $i + +;
- echo "$i: $li <br>"; Contents of the output directory in}}//
- Closedir ($shi); }?>
- </body>