Friday, 16 May 2014

List files in directory using PHP

<?php

//List files in directory using PHP

$dirpath = dirname(__FILE__);// path to directory
if(is_dir($$dirpath))
{
    if($handle = opendir($$dirpath))
    {
        while(($file = readdir($handle)) !== false)
        {
            if($file != "." && $file != ".." && !is_dir($file))
            {
                echo $file.'<br/>';
            }
        }
        closedir($handle);
    }
}

?>

No comments :

Post a Comment

Freelance Jobs