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?

2 Answers 2


get_attached_file returns the server path of an attachment.


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


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


Your Answer

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

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