Guys please help me with this. I am starting the new project and i want to use Umbraco 8, but I am running into the problems all the time.
I checked documentation and it seems that nothing is changed about media service.
I am trying to upload images in Media section with same code which i am using in Umbraco 7 (it works in Umbraco 7) but its not working.
Also i have the same problem when i am using Upload data type but lets start with this...
Model:
[Required]
public int GalleryId { get; set; }
[Required]
public IEnumerable<HttpPostedFileBase> Files { get; set; }
Controller:
[HttpPost]
public ActionResult HandleFormSubmit(ImageGalleryFormViewModel model)
{
if (!ModelState.IsValid)
return CurrentUmbracoPage();
foreach (var file in model.Files)
{
var media = Services.MediaService.CreateMedia(file.FileName, 1051, "Image");
media.SetValue("umbracoFile", file);
Services.MediaService.Save(media);
}
TempData["success"] = true;
return CurrentUmbracoPage();
}
Hi Josip - we have been struggling with the same problem the whole day, using MediaService code that normally works in v7. A file/image in the media section in the specified folder is registered, but there is no thumbnail nor file sizes or anything registered, so basically a useless container to be found ... It must be a bug :-/
Hi Thomsen i hope that someone will tell us soon what is the problem. I would like to use Umbraco 8 for the new project but cant if I dont solve this thing with images :/
For anyone still having trouble with this one. I found this post extremely helpful.
Working from a Surface Controller, I only needed to inject IContentTypeBaseServiceProvider in my controller's constructor because the controller had inherited access to the services.
Working with properties on members and not Media I had to set the value on my instance of IMember, instead of an instance of IMedia, using the same pattern for HttpPostedFileBase as in the example. and Voila!
I'm adding a link to this post because after finding the solution above I realized that my image was being saved but the property value did not save with crops, only the file path was being saved. So if anyone else runs into the same problem perhaps it will help.
Issue with uploading media in Umbraco 8
Guys please help me with this. I am starting the new project and i want to use Umbraco 8, but I am running into the problems all the time. I checked documentation and it seems that nothing is changed about media service.
I am trying to upload images in Media section with same code which i am using in Umbraco 7 (it works in Umbraco 7) but its not working.
Also i have the same problem when i am using Upload data type but lets start with this...
Model:
Controller:
Hi Josip
What error message do you get when executing the code posted if any?
Also have you had a look in the log to see if it reveals any useful information?
/Jan
Hi Jan,
Yes i am getting this one Exception: Could not populate upload auto-fill properties for file '"System.Web.HttpPostedFileWrapper"'.
Any idea ?
Hi Josip - we have been struggling with the same problem the whole day, using MediaService code that normally works in v7. A file/image in the media section in the specified folder is registered, but there is no thumbnail nor file sizes or anything registered, so basically a useless container to be found ... It must be a bug :-/
Hi Thomsen i hope that someone will tell us soon what is the problem. I would like to use Umbraco 8 for the new project but cant if I dont solve this thing with images :/
https://github.com/umbraco/Umbraco-CMS/issues/5102 Is this answer on our problem with uploading media?
Can anybody share with me working example how to upload images programaticaly in Umbraco 8 , please.
Thank you
... I'm still waiting to see the answer too, nothing really works for this issue yet, unfortunately :-/
For anyone still having trouble with this one. I found this post extremely helpful.
Working from a Surface Controller, I only needed to inject IContentTypeBaseServiceProvider in my controller's constructor because the controller had inherited access to the services.
Working with properties on members and not Media I had to set the value on my instance of IMember, instead of an instance of IMedia, using the same pattern for HttpPostedFileBase as in the example. and Voila!
Hope this helps.
I'm adding a link to this post because after finding the solution above I realized that my image was being saved but the property value did not save with crops, only the file path was being saved. So if anyone else runs into the same problem perhaps it will help.
is working on a reply...