how to get file list from directory using php

4
This post i am going to explain about how to get file list from the specified directory using php, This is also very helpful to display your directory file list to your site you can use this concept. This concept only to get the file list only not a file from directory. you should create a directory or folder to the specific location in the name of san web corner. In san web corner folder i am given some of the files for displaying the file name list in website.
get file list from directory

Get file list from Directory:

index.php

<style>
.sanwebcorner
{
margin-left:auto;
margin-right:auto;
border:1px solid #999;
padding:25px;
}
</style>

<h1>Getting file list form Directory</h1>
<?php
$dir    = ‘san web corner’;
$files = scandir($dir);
array_shift($files);
array_shift($files);
 foreach($files as $key=>$value){

   if(!is_dir(“san web corner/”.$value)){

echo “<div class=’sanwebcorner’>”;
    echo $value;
    echo “</br>”;
echo “</div>”;
 
   }
 
 }

?>

Download Code:

Leave a Reply

Your email address will not be published. Required fields are marked *

Close
Your custom text © Copyright 2026. All rights reserved.
Close