HOW TO USE ASP.NET AJAXFILEUPLOADE
1) Create a WebSite
2) Create Downloads/Uploads folder Give write access as shown below.
3) Give Write Permissions to IIS_USRS
4) Add ToolKitScriptManager to asps page
5) Add AJAXFILEUPLOAD to ASPX page
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
MaximumNumberOfFiles="5" onuploadcomplete="AjaxFileUpload1_UploadComplete"
onuploadcompleteall="AjaxFileUpload1_UploadCompleteAll" Mode="Server" />
6) Add event handler for each file AjaxFileUpload1_UploadComplete
protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
try
{
if (e.State == AjaxControlToolkit.AjaxFileUploadState.Success)
{
String szFileName = "./Downloads/" + e.FileName;
System.IO.File.WriteAllBytes(MapPath(szFileName), e.GetContents());
}
}
catch (Exception ex)
{
}
}
Note:This method will be called for each file .
7) onuploadcompleteall called after all files are uploaded.
8) If u get any error
add following section in IIS7 integrated mode
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<handlers>
<add verb="*" name="AjaxFileUploadHandler.axd" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit"/>
</handlers>
</system.webServer>
<system.web.extensions>
No comments:
Post a Comment