Recently I was asked to workaround for uploading the files to SharePoint list pro-grammatically for SharePoint online.
As I can use only sandbox solution,I tried the SPProxyOperation class to upload and save the file.
But its very complex process for staging the package and deployment.
Later I come up with very simple approach,After adding the items to the list I retrieved the Item ID and ListID and passing these parameters to the file "/_layouts/AttachFile.asp?ListID="{GUID}"&ItemID=itemId&isDlg=1 into SPModal dialog.
Click here to upload file to this item