protected void btnUpload_Click(object sender, EventArgs e) { SPSite mySite = SPContext.Current.Site; SPWeb myWeb = mySite.OpenWeb(); UploadDocument(myWeb); } public void UploadDocument(SPWeb site) { if (FileUpload1.HasFile) { SPFolder folder = site.GetFolder("Bill"); SPFileCollection files = folder.Files; Stream fStream = FileUpload1.PostedFile.InputStream; //path of the file to upload byte[] contents = new byte[fStream.Length]; fStream.Position = 0; fStream.Read(contents, 0, (int)fStream.Length); fStream.Close(); string Filename = FileUpload1.FileName; string URL = SPContext.Current.Site.Url + "/Bill/" + Filename; SPFile currentFile = files.Add(URL, contents); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)