Book Image

Kendo UI Cookbook

By : Sagar Ganatra
Book Image

Kendo UI Cookbook

By: Sagar Ganatra

Overview of this book

Table of Contents (18 chapters)
Kendo UI Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the file uploader to upload files to the server


In this recipe, we will look at how the file uploader widget can be used to upload multiple files to the server synchronously.

How to do it…

Let's create a form that will be used to upload the file as follows:

<form method="post" 
  action="/fileUploadService" 
  style="width:500px">

  <input name="files" id="fileUpload" type="file" />
  <input type="submit" value="Submit" class="k-button" />

</form>

The next step is to initialize the file uploader widget by invoking the kendoUpload function on the file input type:

$('#fileUpload').kendoUpload();

This will initialize the file input type to an uploader widget. This uploader widget can then be used to select files and upload them to the server. You can select multiple files and the same would be shown in the list.

When you click on the Submit button, the form is submitted to upload the files in the list. It's a multipart/form-data submission with the file data in the...