scandir to only show folders, not files

后端 未结 4 2019
一整个雨季
一整个雨季 2021-01-01 22:49

I have a bit of PHP used to pulled a list of files from my image directory - it\'s used in a form to select where an uploaded image will be saved. Below is the code:

4条回答
  •  天涯浪人
    2021-01-01 23:37

    Function is_dir() is the solution :

    foreach ($files as $file) {
    
      if(is_dir($file) and $file != "." && $file != "..") $filelist .= sprintf('' . PHP_EOL, $file, $file );
    
    }
    

提交回复
热议问题