PHP directory list question?

Can someone help me with this,I’m stuck.Dont know why this dont work

$myPath = get_bloginfo('wpurl').'/wp-content/uploads/'; // this is full path

function ReadDirList($d){
    $dir = opendir($d);
    $fs = "";
    while($folder = readdir($dir))
    {
        //if(is_dir($folder)){
            $fs = $fs. '<option>'.$folder.'</option>';
        //}
    }
    closedir($dir);
    echo $fs;
}

I call this function <select> <?php ReadDirList($myPath); ?> </select>
tnx in advance.

Related posts

Leave a Reply

1 comment

  1. According to the function reference, get_bloginfo('wpurl') is going to be returning a URL. If you want to access the local file system, you need a real filepath, not a URL.

    Try this for the first line:

    $myPath = WP_CONTENT_DIR.'/uploads/'; // this is full path
    

    WP_CONTENT_DIR is defined in the config file, and should point to the wp-content folder of your installation.