I think I can help you with this one though regardless..
For example, create the upload function and put it on your page:
//upload code here
Then on your href link:
When the 'Attach an image' link is clicked, the upload function is called.