tags:

views:

41

answers:

1

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.

+1  A: 

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.

zombat
tnx,it works,I didn't know that I need a real filepath.thank you very much.
Nice, glad it worked.
zombat