jimmyb
-
5/1/2008 8:30:06 PM
RE:File Upload
my example - creating a document node with several fields and a file attachment
cheers
UserInfo ui = UserInfoProvider.GetUserInfo("administrator"); TreeProvider tree = new TreeProvider(ui);
// Get the parent document CMS.TreeEngine.TreeNode parentNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/Files/Upload", TreeProvider.ALL_CULTURES, true, null, false);
// define the node details // CMS.TreeEngine.TreeNode node = new CMS.TreeEngine.TreeNode("Custom.Page", tree); node.DocumentName = String.Format("{0}-{1} {2}", RowID, Firstname, Surname); // node name // node.DocumentCulture = CMSContext.CurrentUser.PreferredCultureCode; // node culture //
// Set document fields // node.SetValue("RowID", RowID); node.SetValue("Firstname", Firstname); node.SetValue("Surname", Surname);
// insert the document // DocumentHelper.InsertDocument(node, parentNode.NodeID, tree);
// attach file to the existing document // DocumentHelper.AddAttachment(node, "File", FileUpload.PostedFile, tree); DocumentHelper.UpdateDocument(node, tree);
|