Upload Files and Additional Data in a Single Request
Environment
Product | Progress® Telerik® UI Upload for ASP.NET MVC |
Description
I want to upload a file to the server and also write some data into the SQL database after the user fills a form with those values.
How can I send the field values along the AJAX request of the Upload?
Solution
Handle the upload
event of the Upload widget. As a result, you are able to pass additional parameters to the remote call.
function onUpload(e) {
e.data = {
Title: $('#title').val(),
Notes: $('#notes').val()
};
}
On the server, you will get the following parameters in a model object:
public ActionResult UploadFile(IEnumerable<HttpPostedFileBase> files3, TestModel model)
{...}
The model contains the following properties:
public class TestModel
{
public string Title { get; set; }
public string Notes { get; set; }
}