3

All the wordpress functions for retrieving media details seem to give you the web url of a file uploaded. I want to the local server drive/folder path, ideally relative to the install of wordpress. I have the attachment id value to hand so can parse that to a function, if only I knew what it was.

Is this possible with a function built in that I've missed? If not does anyone have anything pre-written for this function?

5

get_attached_file returns the server path of an attachment.

1

You can use the 'wp_upload_dir()' function to get an array of all the path information of the currently configured uploads directory.

Example:

$upload_dir = wp_upload_dir();
echo $upload_dir['path'];

http://codex.wordpress.org/Function_Reference/wp_upload_dir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.