26 April 2005
AspnetUpload™ is an ASP.NET HttpModule that make your web application to upload large file(s) to your web server with realtime progress indicator and no client software or control installation needed. To use this httpmodule in your web application, follow these steps:
-
Copy Bestcomy.Web.Controls.Upload.dll to your project bin folder.
-
In your project, under the Project menu, select the "Add Reference..." option. Use the Browse button to find Bestcomy.Web.Controls.Upload.dll, and click OK. This will include all the functionality of AspnetUpload™ into your project.
-
In your project web.config, which located root of your web application. Add a line in the httpModules section of web.config like this:
<httpModules>
<add name="UploadModule" type="Bestcomy.Web.Controls.Upload.UploadModule,Bestcomy.Web.Controls.Upload" />
</httpModules> -
In the same web.config, beneath configuration tag directly, add AspnetUpload™ configuration settings like this:
<configSections>
<section name="aspnetUploadSettings" type="System.Configuration.NameValueFileSectionHandler,System, Version=1.0.5000.0, Culture=neutral,PublicKeyToken=b77a5c561934e089" />
</configSections>
<aspnetUploadSettings>
<!--
Key Name: lisenceKey
Valid Value: Purchased lisence key from the control author.
-->
<add key="lisenceKey" value="Lisence key purchase from www.aspnetupload.net" />
<!--
Key Name: maxRequestLength
Valid Value: KBytes size of maximum upload file length to accept
-->
<add key="maxRequestLength" value="409600" />
</aspnetUploadSettings> -
In your webform's client side(somename.aspx), which needs upload function, add enctype="multipart/form-data" to the form tag like this:
<form id="Form1" method="post" enctype="multipart/form-data" runat="server"> -
Add html file control in your webform's client side like this:
<input type="file" name="file1">
please do not use runat="server" attribute in this html file control. -
Add a using Bestcomy.Web.Controls.Upload; entry to the form code.
-
Add following code to into Page_Load method:
AspnetUpload upldr = new AspnetUpload();
upldr.RegisterModelessProgressBar("ProgressBar.aspx",btn_upload);
string fpath = Path.Combine(Server.MapPath("."),"Upload");
if(!Directory.Exists(fpath))
Directory.CreateDirectory(fpath);
upldr.set_UploadFolder(fpath);
Above code needs adding a using System.IO; entry to the form code, because above code use some file operation. -
You can use following code to get the uploaded file and save it to the destination folder:
AspnetUpload upldr = new AspnetUpload();
UploadFile file = upldr.GetUploadFile("file1");
if(file != null)
{
string fpath = Path.Combine(Server.MapPath("."),"Upload");
fpath = Path.Combine(fpath,Path.GetFileName(file.get_FileName()));
file.SaveAs(fpath);
}
You can get more example in my demo source.
本文介绍了一种使用AspnetUpload™模块实现ASP.NET应用中大文件上传的方法。通过实时进度指示,无需安装额外软件即可完成大文件的上传工作。文章详细说明了如何配置与集成该模块。
1150

被折叠的 条评论
为什么被折叠?



