# HtmlEditor upload

**URL:** <https://forum.radzen.com/t/htmleditor-upload/5785>\
**Category:** Radzen.Blazor Components\
**Created:** [November 25, 2020, 2:07pm UTC](https://forum.radzen.com/t/htmleditor-upload/5785 "2020-11-25T14:07:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fnils](https://forum.radzen.com/user_avatar/forum.radzen.com/fnils/32/1799_2.png) [@fnils](https://forum.radzen.com/u/fnils)\
**Post date:** [November 25, 2020, 2:07pm UTC](https://forum.radzen.com/t/htmleditor-upload/5785/1 "2020-11-25T14:07:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [November 25, 2020, 2:17pm UTC](https://forum.radzen.com/t/htmleditor-upload/5785/2 "2020-11-25T14:17:30Z")

</div>

> [@fnils](#):
>
> If I understand it correctly after uploading the image I return the path to the HtmlEditor.

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

> [@fnils](#):
>
> 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?

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

---

<div class="post-metadata">

**Author:** ![fnils](https://forum.radzen.com/user_avatar/forum.radzen.com/fnils/32/1799_2.png) [@fnils](https://forum.radzen.com/u/fnils)\
**Post date:** [November 25, 2020, 3:12pm UTC](https://forum.radzen.com/t/htmleditor-upload/5785/3 "2020-11-25T15:12:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fnils](https://forum.radzen.com/user_avatar/forum.radzen.com/fnils/32/1799_2.png) [@fnils](https://forum.radzen.com/u/fnils)\
**Post date:** [November 25, 2020, 3:52pm UTC](https://forum.radzen.com/t/htmleditor-upload/5785/4 "2020-11-25T15:52:09Z")

</div>

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)
