I could not find any good way to do it with IE8 or IE9, so I utilized the OOB AttachFile.aspx form: (I am using SPService to get query string & I am adding input control dynamically with JQuery)
function readyCall() {
//Get Query String
var queryString = $().SPServices.SPGetQueryString();
//Tasks List ID (i.e. 0A347169-CE79-4B7F-B561-C23A7027F06B)
var listID = queryString["List"];
//Task ID (i.e. 14)
var itemId = queryString["ID"];
//Replace the Loading label which is originally added in infopath (I am adding upload control dynamically)
var attachmentDiv = $("div").filter(function () {
return $(this).text() == 'Loading...';
});
attachmentDiv.html('<input type="Button" onclick="OpenDialog(\'/_layouts/AttachFile.aspx?ListId={'+listID+'}&ItemId='+itemId+ '\',600,150)" value="Upload"/>');
}
function OpenDialog(_url, _width, _hight)
{
var options = {
title: "Upload Attchment",
width: _width,
height: _hight,
url: _url };
SP.UI.ModalDialog.showModalDialog(options);
}
