HtmlEditor upload

If I understand it correctly after uploading the image I return the path to the HtmlEditor.

What I would like to do is to save the path in a table in the database and connect it to the table where I store the text. Is that possible in the way it works now?
The reason i want that is so that it will be easier to find the files if I want to delete them.
I don't see a way to do that in the way it works now.

Yes, here is the implementation from our demo: https://github.com/akorchev/blazor.radzen.com/blob/master/Controllers/UploadController.cs#L34

Yes. You can save the file wherever you want and return a URL that can display that file.

First of all I am very happy that you guys made the HtmlEditor. I've been missing this type of component since the beginning of Blazor.

I don't know if I misunderstood you but just in case. I can upload images and save them to disc.

As it is now I can't see how I connect the text to the image. I have the path to the image in the text but I would also like to save the image path in a different table so that I can easily find them on the hard drive when I remove the text I have written.
So when I have saved the file I would like the be able to return an ImageId so I can connect the two tables.
Or send the ArticleId to the image upload controller.

Example of tables:

Articles

  • Id
  • Text
  • List

Images

  • Id
  • ArticleId
  • ImagePath
  • ImageName

If I for instance have a site with news articles and I delete one article I would also like to remove the images that are connected to that article.
I am not sure how that would work today. Because if I set the date on the images for example and two articles are written in about the same time images for both would be removed.
Or if they start writing the articles om one day and then finishes it on the next day. Adding images on both occasions.
From what I can see now I have to search through the text to find the images and then remove them from disc.

I am sorry for the long text. But gratefull for all your work.

I found out how to do it.

In the markup.

<RadzenHtmlEditor @bind-Value="@MainContent" style="height: 500px; margin-bottom: 1rem;" UploadUrl="@uploadpath" Change=@OnChange Paste=@OnPaste Execute=@OnExecute />

In the markup code.

string uploadpath = $"api/upload/image/{ArticleId}";

In the controller

[HttpPost("image/{id}")] public IActionResult Image(IFormFile file, Guid id)