Select media folder to save uploaded images in



I need to set a property on a page to allow the editor to select which asset folder uploaded images should be saved in. Right now, when a user submits an image in an form, I create a blob and just save it under SiteDefenition.Current.GlobalAssetRoot. How do I do this/change the place where I save the uploaded images?

Jan 29, 2014 13:01

Hi, maybe this is not exactly what you want (asset folder), but you should be able to define the following property:

[Display(GroupName = SystemTabNames.Content, Order = 1)]
public virtual ContentReference MyFolder { get; set; }

This will let you select a folder (only a folder) from the Edit interface, which you then can use for your file upload:

var repository = ServiceLocator.Current.GetInstance<IContentRepository>();
var file = contentRepository.GetDefault<GenericFile>(MyFolder);
...create blob, write and save file etc...

Jan 30, 2014 10:29

That was exactly what I needed, thanks!

Jan 30, 2014 11:18

Excellent, I was looking for this as well.

Jul 21, 2015 11:31
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.