Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm exploring umbraco 8 latest version.
I'm trying to create new Image media within surfaceController. My problem is
code executes successfully but it doesn't create image in media section.
public class ContactFormController : SurfaceController
// GET: Tour
public ActionResult Submit(TourViewModel model, HttpPostedFileBase file)
var fileName = Path.GetFileName(file.FileName);
string imgPath = @"Path of image file aka TestImage.jpg";
var ms = Services.MediaService;
using (var file1 = new FileStream(imgPath, FileMode.Open))
var parent = ms.GetRootMedia().FirstOrDefault(); // or -1 for root media object
var media = ms.CreateMedia("TestImage", parent, Constants.Conventions.MediaTypes.Image);
media.SetValue(Constants.Conventions.Media.File, file1); // save image inside folder
var mediaSaved = ms.Save(media);
Here is output:
Can anyone suggest why image is not loading in mediaSection ?
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted