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
[HttpPost]
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);
}
return RedirectToCurrentUmbracoPage();
}
}
Here is output:
Can anyone suggest why image is not loading in mediaSection ?
Image not showing in mediaSection in Back Office
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.
Here is output:![enter image description here](/media/upload/a1ff0525-2809-4456-af8f-d0e115c88270/errorumb.PNG)
Can anyone suggest why image is not loading in mediaSection ?
is working on a reply...