PHP directory traversal code

WBOY
Release: 2016-07-25 08:42:32
Original
948 people have browsed it

PHP directory traversal

  1. //php directory traversal
  2. function showDetail($dirname){
  3. $ds = opendir($dirname);
  4. while($file = readdir($ds) ){
  5. $path = $dirname."/".$file;
  6. if($file != "." && $file != ".."){ //This is a trap
  7. if(is_dir($path) ){
  8. showDetail($path); //Recursive call, if the directory is read, continue reading
  9. }else{
  10. echo $path."
    ";
  11. }
  12. }
  13. }
  14. }
  15. $dirname="test"; //Test a directory
  16. showDetail($dirname);
  17. ?>
Copy code

PHP


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!