New to Kendo UI for jQueryStart a free 30-day trial

Upload Files and Additional Data in a Single Request

Environment

ProductProgress® 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.

JavaScript
function onUpload(e) {
	e.data = {
		Title: $('#title').val(),
		Notes: $('#notes').val()
	};
}

On the server, you will get the following parameters in a model object:

C#
public ActionResult UploadFile(IEnumerable<HttpPostedFileBase> files3, TestModel model)
{...}

The model contains the following properties:

C#
public class TestModel
{
	public string Title { get; set; }

	public string Notes { get; set; }
}

See Also