3

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.

2
  • 1
    How, exactly, does it fail? When asking for help, always state the behavior you expect and the behavior you get, including any error messages. Commented Apr 22, 2010 at 22:46
  • Sorry,I'm kind a new here.It prints empty string,like $fs is empty Commented Apr 22, 2010 at 22:49

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.