If you need to upload a file into a SharePoint document library through code you can get started with this MSDN article: How to: Upload a File to a SharePoint Site from a Local Folder.
In case you need to do the upload the file as an attachment to a custom list using the object model, the approach is slightly different. Adding a file to the list item can be done by accessing the Attachments collection of the SPListIem:
//code snippet
SPList list = web.Lists[new Guid("my list id")];
if (list != null)
{
web.AllowUnsafeUpdates = true;
SPListItem item = list.Items.Add();
item["Title"] = "my title";
if (fileAttachment.PostedFile != null && fileAttachment.HasFile)
{
Stream fStream = fileAttachment.PostedFile.InputStream;
byte[] contents = new byte[fStream.Length];
fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();
fStream.Dispose();
SPAttachmentCollection attachments = item.Attachments;
string fileName = Path.GetFileName(fileAttachment.PostedFile.FileName);
attachments.Add(fileName, contents);
}
item.Update();
web.AllowUnsafeUpdates = false;
}
//snippet end