List all files of a directory with php

Free Scripts :: PHP :: Files and Folders :: List all files of a directory with php

Author: Salman Javaid

Website: http://www.salman.be

  • How to list all files of a directory with php.
  • Display all files from a folder with php.

This scripts lists all files and folders located at given path.

Script

$path='products/images/';
$handle=opendir($path);
while (($file = readdir($handle))!==false){
    if ($file!="." && $file!=".."){
        echo $file . ', ';
    }
}

Output

img01.jpg, img02.jpg, img05.jpg, img07.jpg, img15.jpg

Comments

No comments. Be the first one.

Leave a comment

Full Name*
Comments*
Security Code*

Our Partners

Getty Icons  Salman Creations
Free High Quality Images  Learn Free Languages 
Opal Hosting  R-Tech Solutions
  • Submit a Script

    Click here to submit your script.