I have a custom post which has a meta tag that needs to be using a file upload (for video files). I am wondering, what is the correct way of adding an “Upload” button that points to the WordPress media uploader and sets the url of the selected uploaded file to the text field that caused that associates the upload button.
I am not looking for code on creating the actual meta tag option, but for a way to actually add a WordPress media upload button properly.
See this media uploader skeleton. You can also use it in your custom markup, like Meta Box.
A hint, check, that you only use the scripts on the page, where you active your Meta Box. Otherwise is it often a problem on the default pages and the uploader.
Now a attempt to clear the important parts to include the uploader to your custom part.
First include an button in the meta box:
Now enqueue the scripts:
The last part is your custom script to use the thickbox and the uploader inside this.
Solution:
1) in your functions.php, add the block for registering the necessary scripts:
2) and then add metabox block:
p.s. in case you need multiple fields, then you can easily do like this: http://pastebin.com/raw/xpU1ch2W