PHP File Browsing function

Source: Internet
Author: User
Tags date parent directory php file

PHP file browsing function, the following code:

 
 
  1. <title> File Browsing </title>
  2. <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
  3. <style type= "Text/css" >
  4. <!--
  5. a:link {text-decoration:none;}
  6. a:visited {text-decoration:none;}
  7. a:hover {text-decoration:none;}
  8. a:active {text-decoration:none;}
  9. . style1 {font-size:12px}
  10. -->
  11. </style>
  12. <body>

  13. <div align= "center" >
  14. <table width= "height=" border= "1" align= "Center" >
  15. <TR align= "center" valign= "Middle" bgcolor= "#A5F5BF" >
  16. <th width= "height=" align= "center" valign= "middle" ><span class= "Style1" > Project name </span></th >
  17. <th width= "align=" "Center" valign= "middle" ><span class= "Style1" > Size </span></th>
  18. <th width= align= "center" valign= "middle" ><span class= "Style1" > Date created </span></th>
  19. <th width= "180" align= "center" valign= "middle" ><span class= "Style1" > Last modified </span></th>
  20. </tr>
  21. <?php
  22. if (!isset ($_get[mulu]) empty ($_get[mulu)) $dqml =getcwd ();//Get Script directory
  23. else $DQML =$_get[mulu];
  24. ChDir ($DQML);//Change current directory
  25. echo "Current directory:". GETCWD (). <br> ";
  26. $ML = Opendir ($DQML); Open Directory
  27. while ($hqml = Readdir ($ml)) {//Looping through directories and files in the directory
  28. echo "<tr><td align= ' center ' valign= ' middle ' bgcolor= ' #A5F5BF ' > ';
  29. if (Is_dir ($HQML)) {//judgment is directory
  30. if ($hqml = = ".") {
  31. $mulu =GETCWD ()///Display the current directory
  32. echo "<a href= $php _self?mulu= $mulu ><span class= ' style1 ' > Lock </span></a> '; }
  33. ElseIf ($hqml = = "...") {
  34. $mulu =getcwd (). " \\.."; Parent Directory
  35. echo "<a href= $php _self?mulu= $mulu ><span class= ' style1 ' > Parent directory </span></a>";
  36. }else{
  37. $mulu =getcwd (). "  \ $hqml "; Sub Directory
  38. echo "<a href= $php _self?mulu= $mulu > $hqml </a>"; }
  39. }else{
  40. $ext =substr ($HQML, Strrpos ($HQML, "."));
  41. if (Strtoupper ($ext) = = ". PHP "Strtoupper ($ext) = =". TXT ") {
  42. $mulu =GETCWD ();
  43. echo "<a href=./example25.php?mulu= $mulu &filename= $hqml &type= $ext > $hqml </a>";
  44. }else{
  45. echo "$HQML"; }  }
  46. if (Is_dir ($HQML)) $file _size= "directory";
  47. else $file _size=round (filesize ($HQML)/1024). K ";
  48. echo "<td align= ' center ' valign= ' middle ' bgcolor= ' #A5F5BF ' > $file _size</td>";
  49. $create _time=date ("y-m-d H:i:sa", Filectime ($HQML));
  50. echo "<td align= ' center ' valign= ' middle ' bgcolor= ' #A5F5BF ' > $create _time</td>";
  51. $update _time=date ("y-m-d H:i:sa", Filemtime ($HQML));
  52. echo "<td align= ' center ' valign= ' middle ' bgcolor= ' #A5F5BF ' > $update _time</td>"; }
  53. Closedir ($ML);?>
  54. </table>
  55. </div>
  56. </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.