<SfRichTextEditor @ref="sfRichText" @bind-Value="_templateContent" Height="600px" EnableResize="true" EditorMode="EditorMode.HTML">
<RichTextEditorImageSettings SaveUrl="@("api/Image/Save/"+_htmlContentId)" Path="@("/images/DocTemplates/"+_htmlContentId+"/")"></RichTextEditorImageSettings>
</SfRichTextEditor>
<SfButton OnClick="@changeDropArea">Change DropArea</SfButton>
<SfRichTextEditor @bind-Value="@Value">
<RichTextEditorImageSettings SaveUrl="api/Image/Save" Path="@Path"/>
<RichTextEditorEvents BeforeUploadImage="@beforeUploadImage"></RichTextEditorEvents>
</SfRichTextEditor>
@code{
public string htmlContentId { get; set; } = "dropArea";
//CurrentPath
string Path = "./Images/DocTemplate/dropArea/";
private string Value { get; set; } = "<p>Syncfusion RichTextEditor</p>";
public void changeDropArea()
{
//Changes the Path value
this.htmlContentId = "normalImage";
this.Path = "./Images/DocTemplate/" + this.htmlContentId + "/";
}
public void beforeUploadImage(ImageUploadingEventArgs args)
{
//Will be sent to server save action for the folder location change.
args.CustomFormData = new List<object> { new { page = htmlContentId } };
}
} |
[HttpPost("[action]")]
[Route("api/Image/Save")]
public void Save(IList<IFormFile> UploadFiles)
{
try
{
foreach (var file in UploadFiles)
{
//Retrieve the value
var folderName = Request.Form["page"];
if (UploadFiles != null)
{
string targetPath = hostingEnv.ContentRootPath + \\wwwroot\\Images\\DocTemplate\\ + folderName +"\\";
string filename = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
. . .
}
}
}
catch (Exception e)
{
. . .
}
} |