首页 > 代码库 > Sitecore操作Media上传图片
Sitecore操作Media上传图片
try { Sitecore.Resources.Media.MediaCreatorOptions options = new Sitecore.Resources.Media.MediaCreatorOptions(); options.Database = Sitecore.Configuration.Factory.GetDatabase("master"); options.Language = Sitecore.Globalization.Language.Parse(Sitecore.Configuration.Settings.DefaultLanguage); options.Versioned = Sitecore.Configuration.Settings.Media.UploadAsVersionableByDefault; options.Destination = "/sitecore/media library/Pampers/Images/Expert/doctor1"; options.FileBased = Sitecore.Configuration.Settings.Media.UploadAsFiles; string filePath = "E:\\doctor1.png"; Sitecore.Data.Items.MediaItem sampleMedia = MediaManager.Creator.CreateFromFile(filePath, options); this.divError.InnerText = sampleMedia.ID.ToString(); } catch (Exception ex) { this.divError.InnerText = ex.Message; }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。