Rabu, 28 Oktober 2015

Php How To Get List Of All Filenames From A Folder

Php How To Get All Files Names From A Folder


________________________________________________________


In this Php Tutorial we will see How To Retrieve All Files Names In A Directory Using Php .

I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .



 




Php Source Code:

<?php

$dir_path = "folder/";
$options = "";
if(is_dir($dir_path))
{
    $files = opendir($dir_path);
    {
        if($files)
        {
          while(($file_name = readdir($files)) !== FALSE)
          {
              if($file_name != '.' && $file_name != '..')
              {
               // select option with files names
               $options = $options."<option>$file_name</option>";   
               
               // display the file names
               echo $file_name."<br>";
              }
          }
        }
}
}

?>


<!DOCTYPE html>
<html>
    <head>
        
    <title>PHP GET List Of FILES NAMES FROM A Directory </title>
    </head>
    
    <body>
        
        <select>
            <?php echo $options;?>
        </select>
        
    </body>
</html>


php files names



                     

Bagikan

Jangan lewatkan

Php How To Get List Of All Filenames From A Folder
4/ 5
Oleh

Subscribe via email

Suka dengan artikel di atas? Tambahkan email Anda untuk berlangganan.