Portal Engine
Version 3.x > Portal Engine > File Upload View modes: 
User avatar
Member
Member
jamesbbb@telstra.com - 4/21/2008 7:42:00 PM
   
File Upload
Are there any examples available which show how to upload files to the CMS ?
i am hoping there is a basic interface/method which handles the storing and retrieval of files on the database/filesystem depending on what is set in the Site Manager/Settings

cheers
james

User avatar
Member
Member
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);

User avatar
Kentico Developer
Kentico Developer
kentico_zbysekn - 7/29/2008 7:08:32 AM
   
RE:File Upload
Hi Jimmy,
Thank you for your example.

Another examples could be find in Developer's guide(http://www.kentico.com/docs/devguide/content_management_internals.htm)

Best Regards,
Zbysek Nemec