How do I do this?
You can achieve this with help of assembler service (http://help.adobe.com/en_US/livecycle/10.0/Services/WS92d06802c76abadb712193f912dbeb3c6db- 8000.html)
This link will help you in creating a DDX to do the same (http://help.adobe.com/en_US/livecycle/10.0/ddxRef.pdf)
Jump to Section 'Attaching files to a PDF document'. Hope this helps.
These documentation is from ES3 version.
Similar documentation is present for other versions of LiveCycle too.