Pages

Sunday 2 February 2014

How to develope Multiple File Upload with Progress Bar using jQuery in Asp.net c#

How to develope Multiple File Upload with Progress Bar using jQuery in Asp.net c#



<html xmlns="http://www.w3.org/1999/xhtml">
 <head runat="server">
 <title>jQuery Upload multiple files in asp.net</title>
 <script src="http://code.jquery.com/jquery-1.8.2.js">
</script>
 <link href="uploadify.css" rel="stylesheet" type="text/css" /> 
<script src="js/jquery.uploadify.js" type="text/javascript">
</script> <script type="text/javascript">
 $(function() {
 $("#file_upload").uploadify({
 'swf': 'uploadify.swf',
 'uploader': 'Handler.ashx',
 'cancelImg': 'cancel.png',
 'buttonText': 'Select Files',
 'fileDesc': 'Image Files',
 'fileExt': '*.jpg;*.jpeg;*.gif;*.png', 'multi': true, 'auto': true
 });
 }) </script>
 </head>
 <body>
 <form id="form1" runat="server">
 <div> <asp:FileUpload ID="file_upload" runat="server" />
 </div>
 </form>
 </body>
 </html>





<%@ WebHandler Language="C#" Class="Handler" %>
 using System.Web;
 public class Handler : IHttpHandler
 {
 public void ProcessRequest (HttpContext context)
 {
 context.Response.ContentType = "text/plain";
 HttpPostedFile uploadFiles = context.Request.Files["Filedata"];
 string pathToSave = HttpContext.Current.Server.MapPath("~/UploadFiles/") + uploadFiles.FileName;
 uploadFiles.SaveAs(pathToSave);
 }
 public bool IsReusable
 {
 get
{
return false;
 }
 }
 }






Imports System.Web    
Public Class   Handler2 : Implements IHttpHandler  
  Public Sub   ProcessRequest(ByVal context As HttpContext)
 Implements   IHttpHandler.ProcessRequest  context.Response.ContentType = "text/plain"
 Dim uploadFiles As HttpPostedFile = context.Request.Files("Filedata")
 Dim pathToSave As String = HttpContext.Current.Server.MapPath("~/UploadFiles/") & uploadFiles.FileName
 uploadFiles.SaveAs(pathToSave)
 End Sub
 Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
 Get
 Return False
 End
Get
 End Property
 End Class







No comments:

Post a Comment