title: How to upload a file in Umbraco 8 and set it's value to file upload datatype
body: <p><a href="https://i.stack.imgur.com/HWP9K.png" rel="nofollow noreferrer">Image for uploaded file</a>Is there a simple way to upload file to a media folder in Umbraco 8 at controller level, and setting it as a value for a file upload datatype. This is the code I am have used for version 7 and it seemed to work fine:</p>
  
  <pre><code>        if (model.FileUpload != null)
          {
              IMediaService mediaService = Services.MediaService;
              var media = mediaService.CreateMedia(model.FileUpload.FileName, 1834, "File");
              media.SetValue("umbracoFile", model.FileUpload.InputStream);
              mediaService.Save(media);
              content.SetValue("entry", $"media/{media.Key}");
  
          }
  </code></pre>