PHP traverses all files under the specified folder

Source: Internet
Author: User

PHP traverses all files under the specified folder, as follows:

 
  1. <?php
  2. Session_Start ();
  3. if ($Submit = = "Submit") {
  4. $shili = $file _dir;
  5. }
  6. ?>
  7. <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
  8. <title> traverse all files in the specified directory-www.cxybl.com</title>
  9. <body>
  10. <table width= "height=" border= "0" cellpadding= "0" cellspacing= "0" background= "images/324.jpg" >
  11. <form name= "Form1" method= "Post" action= "index.php" >
  12. <tr>
  13. <TD width= "132" height= "> </td>"
  14. <TD width= "135" > </td>
  15. <TD width= "> </td>"
  16. </tr>
  17. <tr>
  18. <TD height= > </td>
  19. <TD align= "center" >
  20. <input name= "File_dir" type= "text" id= "File_dir" size= "a" maxlength= "M" ></td>
  21. <td> <input type= "Submit" name= "Submission" value= "submitted" ></td>
  22. </tr>
  23. <tr>
  24. <TD height= "> </td>"
  25. <td> </td>
  26. <td> </td>
  27. </tr>
  28. </form>
  29. </table>
  30. <?php
  31. $shili = $file _dir;
  32. if (!file_exists ($shili)) {
  33. Print $shili. " Directory does not exist! ";
  34. }else{
  35. $i = 0;
  36. if (Is_dir ($shili)) {//detect whether it is a legal directory
  37. if ($shi = Opendir ($shili)) {//Open Directory
  38. while ($li = Readdir ($shi)) {//Read directory
  39. $i + +;
  40. echo "$i: $li <br>"; Contents of the output directory in}}//
  41. Closedir ($shi); }?>
  42. </body>






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.