May be you should take a look at this tutorial, it should be useful

http://www.opserver.de/coni_users/web_users/pirvu/au/tutorials/zipped/attach_entity.zip