I'm trying to use Krajee's Bootstrap Fileinput (http://plugins.krajee.com/file-input) and having some problems.
The input field is in a form which has a submit button
<form method="post" enctype="multipart/form-data" asp-action="CreeAnnonce" asp-controller="Vendeur">
My problem is when I upload files with the Fileinput, it runs the action method CreeAnnonce as if I click on the submit button of the form
public async Task<IActionResult> CreeAnnonce(Annonce annonce, IFormFile[] photo)
{
...
I would like to run another action method (in AJAX) when I click on "upload" but I don't know how.
Please help me
You can try to add
onsubmit
to form,and call ajax withonsubmit
:js:
result: