While developing a project you might come across a situation where you need to upload multiple files at a time. If you working on Asp.net project and you come across similar situation no need to worry you have nice options to accomplish this task.
We can make use of AjaxFileUpload Control. It offers several features.
1. Upload multiple files at a time.
2. Progress bar to display file upload status.
3. Drag and drop facility.
In order to use AjaxFileUpload control first you need to add AjaxControlToolkit to your application, wanted to learn how to do it? Please refer my previous post on How to add AjaxControlToolkit to Visual Studio 2012.
The best part of this control is you can control which file types you want to upload. You can make use of AllowedFileTypes property. You can simply allow different file types separated by commas in AllowedFileTypes control.
Using this Control is very simple you just need to drag this control from ToolBox and drop it on your .aspx page, add directive to register assembly and add script manager and you are all set to use AjaxFileUpload control. Registering assembly and adding script manager shown in code given below.
// Register Assembly
< %@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
// Add Script Manager
// AjaxFileUpload Control
AjaxFileUpload Control Properties :
- ThrobberID – The ID of a control that is shown while the file is uploading. The throbber image is displayed for browsers that do not support the HTML5 File API.
- ContextKeys – A dictionary that can be used to pass information to the server when a file is uploaded.
- MaximumNumberOfFiles – This property enables you to limit the number of files that a user can add to the upload queue.
- AllowedFileTypes – This property enables you to restrict the types of files that can be uploaded. You can assign a comma delimited list of file extensions to this property.
- IsInFileUploadPostBack – This property has the value true when a page is created in response to an AjaxFileUpload asynchronous postback.