Get Files In Directory


In this tutorial I will teach you how to get a list of files in any directory using PHP.
Here we enter the path to the folder that we want to list the items inside images/people

// Search the people folder
foreach (new DirectoryIterator('images/people') as $file) {

// If this is a file then get the name
  if ($file->isFile()) {
      echo $file->getFilename() . "\n";

That’s it. If you find this tutorial useful, leave a comment.

Please Post Your Comments & Reviews

Welcome to Western Studios

We provide professional website and mobile softwares including Joomla, Wordpress and more.