Vote count:
0
I want to rename or want to give the name to uploaded media item, but it always uploaded as unnamed as item(media) name. Following is my code.
public static void UploadImage(int customerID,FileUpload fup)
{
using (new SecurityDisabler())
{
var options = new Sitecore.Resources.Media.MediaCreatorOptions
{
AlternateText =customerID.ToString(),
FileBased = false,
IncludeExtensionInItemName = false,
KeepExisting = false,
Versioned = false,
Destination = "/sitecore/media library/temp",
Database = Sitecore.Configuration.Factory.GetDatabase("master")
};
var filepath = HttpContext.Current.Server.MapPath(fup.FileName);
var creator = new MediaCreator();
var mediaItem = creator.CreateFromStream(fup.PostedFile.InputStream, filepath, options);
MediaItem myFile = mediaItem;
myFile.Name = customerID.ToString(); // unable to give becasue it read only
}
}
asked 1 min ago
Renaming Sitecore Media Item using c#
Aucun commentaire:
Enregistrer un commentaire