Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kyle 24 posts 63 karma points
    Nov 13, 2013 @ 18:52
    Kyle
    0

    Trouble saving uploaded media file to "Upload Data Type" field

    Hi,

    I have managed to add a File upload field to my member profile area and save the file to the media section, however I can't seem to find the right combination of path & file name for the string to save in Upload field on the member.

    I've tried a combination of path and ID, the link in the admin next to the upload field is : "/media/1152" How do I get the correct path to the file ?

    Thanks,

    Kyle

    Here's my code so far:

    if (model.CVFile != null)
        {
            var mediaService = Services.MediaService;
            //CreateMedia takes the name of the media you are created, the id of the parent and finally the alias of the MediaType that you want the media to be based on.
            var media = mediaService.CreateMedia(model.CVFile.FileName, 1137, "File");
            mediaService.Save(media);
    
            media.SetValue("umbracoFile", model.CVFile);
            //And then save it similar to the above snippet
            mediaService.Save(media);
    
            updateMember.getProperty("CVFile").Value = media.Id;
        }
    
  • Ian Mone 8 posts 88 karma points
    Jun 26, 2017 @ 04:38
    Ian Mone
    0

    Did you ever find a solution for this?

Please Sign in or register to post replies

Write your reply to:

Draft