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: In the same web.config, beneath configuration tag directly, add AspnetUpload™ configuration settings like this: In your webform's client side(somename.aspx), which needs upload function, add enctype="multipart/form-data" to the form tag like this: Add html file control in your webform's client side like this: Add a using Bestcomy.Web.Controls.Upload; entry to the form code. Add following code to into Page_Load method: You can use following code to get the uploaded file and save it to the destination folder: You can get more example in my demo source.How to use AspnetUpload™ in your web application
<httpModules>
<add name="UploadModule" type="Bestcomy.Web.Controls.Upload.UploadModule,Bestcomy.Web.Controls.Upload" />
</httpModules>
<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>
<form id="Form1" method="post" enctype="multipart/form-data" runat="server">
<input type="file" name="file1">
please do not use runat="server" attribute in this html file control.
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.
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);
}
AspnetUpload使用方法
最新推荐文章于 2018-07-17 16:27:58 发布
