get_post_meta
returns the ID of the post attachment. To get the file name of a custom field called pdf
:
$doc_id = get_post_meta( get_the_ID(), 'pdf', true );
$filename = basename( get_attached_file( $doc_id ) );
echo $filename;
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.