Following code can be use to upload a document to document library with in specific site.
SPSite mySite = new SPSite("http://
SPWeb spWeb = mySite.OpenWeb();
SPDocumentLibrary docLib = (SPDocumentLibrary) spWeb.Lists["
SPFolder folder = docLib.RootFolder;
using( FileStream fs = File.OpenRead("
SPFile file= folder.Files.Add("
I hope this will be helpful for those who wants to update documents and also needs to perform few custom actions on uploaded documents.