kentico_edwardh
-
6/25/2012 12:01:30 PM
RE:Automatic FileName generation on User Contribution
Hello,
You should be able to get the file name of the uploaded document by using the code example below, which can also be found in the following file -~\CMSModules\Content\Controls\Attachments\FileUpload.ascx.cs
// Create new document string fileName = Path.GetFileNameWithoutExtension(ucFileUpload.FileName);
node = TreeNode.New("CMS.File", tree); node.DocumentCulture = CMSContext.PreferredCultureCode; node.DocumentName = fileName;
// Load default values FormHelper.LoadDefaultValues(node);
node.SetValue("FileDescription", ""); node.SetValue("FileName", fileName); node.SetValue("FileAttachment", Guid.Empty);
Another approach would be to edit the field in the document type, and set the Document name source field to FileName for the field which is using the direct uploader.
Best Regards, Edward Hillard
|