Hi, I am using DevExtreme for ASP.NET Core and the HtmlEditor. I want to allow the user to upload images. For this I use :
…
x.AddSimpleFor(v => v.Content)
.Editor(e => e
.HtmlEditor()
.CustomizeModules("CustomizeHtmlEditor")
.ID("edit-html-editor")
.ImageUpload(imageUpload =>
{
imageUpload.Tabs(
tabs =>
{
tabs.Add().Name(HtmlEditorImageUploadTab.File);
tabs.Add().Name(HtmlEditorImageUploadTab.Url);
}
);
imageUpload.FileUploadMode(HtmlEditorImageUploadFileUploadMode.Server);
imageUpload.UploadUrl("/imager/upload");
imageUpload.UploadDirectory("/uploaded-images/");
imageUpload.FileUploaderOptions(x => x.MaxFileSize(10 * 1024 * 1024));
})
…
I have written a controller ImagerController and the POST endpoint upload. I receive the data of the image in this controller. So far everything is okay.
I have to make sure that the uploaded image has a unique name, otherwise the image of a user with the same name might be overwritten (or used if not overwritten). The html editor must receive and use the new name. To do this, my controller creates a new unique name for the image and returns the path of the image.
Unfortunately, the HTML editor requires the original name.
Question: how can I make the html editor accept the new name?
It seems a "bit impractical" to expect the user to use a globally unique name for all his images. I also don't want to store the images in a database.
Thanks for your help!
BR V
Hi,
The HTML Editor component does not allow you to use the name of the file returned from the server. I am currently researching if this can be implemented in a custom solution. I will update this ticket once I have any news.
Thanks,
Alisher