Add "FlashUpload.dll" to Bin folder of ASP.Net.
Upload.cs class
using
System;
using
System.Data;
using
System.Configuration;
using
System.Web;
using
System.Web.SessionState;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
System.IO;
public
class Upload
: IHttpHandler,
IRequiresSessionState
{
public bool
IsReusable
{
get { return
true; }
}
public void
ProcessRequest(HttpContext context)
{
if ( context.Request.Files.Count > 0 )
{
for(int
j = 0; j < context.Request.Files.Count; j++)
{
HttpPostedFile uploadFile =
context.Request.Files[j];
if (uploadFile.ContentLength >
0)
{
uploadFile.SaveAs(context.Server.MapPath("~/Uploads/"+uploadFile.FileName));
}
}
}
}
}
Web.config
In
<system.web>
of config
file add the following tags
<httpHandlers>
<!--
The httpHandler that files are uploaded to, defined in App_Code/Upload.cs
-->
<remove
verb="POST,GET"
path="Upload.cs"/>
<add
verb="POST,GET"
path="Upload.cs"
type="Upload"/>
</httpHandlers>
<!--
The maximum files size allowed
-->
<httpRuntime
maxRequestLength="1550000"/>
<customErrors
mode="Off"
/>
Default.aspx
<%@
Page Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
EnableEventValidation="false"
%>
<%@
Register Assembly="FlashUpload"
Namespace="FlashUpload"
TagPrefix="FlashUpload"
%>
<!DOCTYPE
html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head
runat="server">
<title>Untitled
Page</title>
</head>
<body>
<form
id="form1"
runat="server">
<div>
<asp:LinkButton
ID="LinkButton1"
runat="server"
Visible="False">LinkButton</asp:LinkButton>
<br
/>
<FlashUpload:FlashUpload
ID="flashUpload"
runat="server"
UploadPage="Upload.cs"
OnUploadComplete="UploadComplete()"
FileTypeDescription="Images"
FileTypes="*.*"
UploadFileSizeLimit="1800000"
TotalUploadSizeLimit="2097152"
/>
</div>
</form>
</body>
</html>
Default.aspx.cs
using
System;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
public
partial class
_Default : System.Web.UI.Page
{
protected void
Page_Load(object sender,
EventArgs e)
{
if (!IsPostBack)
{
string jscript =
"function UploadComplete(){" +
ClientScript.GetPostBackEventReference(LinkButton1,
"") +"};";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"FileCompleteUpload", jscript,
true);
}
}
}