Hello, I'm currently using the HTML Editor within this form:
<EditForm Model="@newBlogPost" OnValidSubmit="CreateNewBlogPost">
<DataAnnotationsValidator />
<div class="form-group">
<label for="title">Title</label>
<InputText id="title" @bind-Value="newBlogPost.Title" class="form-control" />
<ValidationMessage For="@(() => newBlogPost.Title)" />
</div>
<div class="form-group">
<label for="url">Url</label>
<InputText id="url" @bind-Value="newBlogPost.Url" class="form-control" />
<ValidationMessage For="@(() => newBlogPost.Url)" />
</div>
<RadzenHtmlEditor @bind-Value=newBlogPost.Content UploadUrl="upload/image" style="height: 300px;" />
<button type="submit" class="btn btn-primary">Create</button>
<ValidationSummary />
</EditForm>
<RadzenDialog />
<RadzenNotification />
<RadzenContextMenu />
<RadzenTooltip />
I'm trying to insert images into the HTML Editor, however when I click the image icon and it brings up a box that allows me to select an image, the ok button doesn't do anything and nothing happens. I assume it would be a problem with my controller, which I just used the one from the samples on GitHub, or:
[HttpPost("upload/image")]
public IActionResult Image(IFormFile file)
{
try
{
var fileName = $"upload-{DateTime.Today.ToString("yyyy-MM-dd")}-{Guid.NewGuid()}{Path.GetExtension(file.FileName)}";
using (var stream = new FileStream(Path.Combine(environment.WebRootPath, fileName), FileMode.Create))
{
// Save the file
file.CopyTo(stream);
// Return the URL of the file
var url = Url.Content($"~/{fileName}");
return Ok(new { Url = url });
}
}
catch (Exception ex)
{
return StatusCode(500, ex.Message);
}
}
Is my controller incorrect? I don't believe I'm injecting anything wrong, it should be able to work with string because of the demo. Just curious. Thanks.