Quantcast
Channel: Marius' Blog » PHP
Viewing all articles
Browse latest Browse all 5

List all files from a folder with PHP

$
0
0

This function will list all the files from a folder. Give the folder as a parameter.

PHP code:

listFolder("folder/");

function listFolder($folder){
    $folderData = opendir($folder);

    while (($file = readdir($folderData)) !== false){
        echo "File name: ".$file."<br />";
        echo "File type: ".filetype($folder.$file)."<br />";
        echo "File path: ".$folder.$file."<br /><br />";
    }

    closedir($folderData);
}


Viewing all articles
Browse latest Browse all 5

Trending Articles