Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

kentico 13 api save attachment

// Gets the first page located under /Articles
TreeNode page = new DocumentQuery<TreeNode>()
                    .Path("/Articles", PathTypeEnum.Children)
                    .OnSite("MySite")
                    .Culture("en-us")
                    .TopN(1)
                    .FirstOrDefault();

if (page != null)
{
    DocumentAttachment attachment = null;

    // Prepares the path of the file
    string file = System.Web.HttpContext.Current.Server.MapPath("/FileFolder/file.png");

    // Inserts the attachment into the 'ArticleTeaserImage' field and updates the page
    attachment = DocumentHelper.AddAttachment(page, "ArticleTeaserImage", file);
    page.Update();
}
Source by docs.xperience.io #
 
PREVIOUS NEXT
Tagged: #kentico #api #save #attachment
ADD COMMENT
Topic
Name
8+2 =