Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8832

Importing Image into File Field Type

$
0
0
We are trying to upload several images into existing pages in Kentico v9 using an import program written by us. For each image, we are creating a new node of a custom page type. One of the fields in this custom page type is a data type of @File@ called @UploadedImage.@ I have the images saved locally on my computer and have a console program to import them. The import program first creates the node to store the image using the custom page type. I then try to upload the image from my local computer to the Kentico server. Here's what I have:var attachmentNode = TreeNode.New(FILE_PAGE_TYPE); attachmentNode.DocumentName = Path.GetFileName(imagePath); attachmentNode.DocumentCulture = galleryNode.DocumentCulture; //Assign the filename attachmentNode.SetValue(@FileTitle@, Path.GetFileName(imagePath)); DocumentHelper.InsertDocument(attachmentNode, galleryNode); //Save the file into the attachment AttachmentInfo attachmentInfo = DocumentHelper.AddUnsortedAttachment(attachmentNode, Guid.NewGuid(), imagePath, new TreeProvider()); attachmentNode.SetValue(@UploadedImage@, attachmentInfo.AttachmentBinary); //Publish the attachment node attachmentNode.Publish(); My problem is nothing is being loaded into the File field. I appreciate any help anyone can give to get the binary data into the File field.

Viewing all articles
Browse latest Browse all 8832

Trending Articles