During the development of my enterprise management system, the biggest problem encountered was the upload of large files. To upload large files in asp or php, you need to use components (this is restricted by the VM ). However, it seems much easier to upload large files in asp.net. The following provides the asp.net large file upload solution.
Paste the code and do. net development. What do you mean at first glance?
1. btnSave save file submit button event
[Html]
/// <Summary>
/// BtnSave save file submit button event
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void btnSave_Click (object sender, EventArgs e)
{
Foreach (UploadedFile file in RadUploadContext. Current. UploadedFiles)
{
String Path = Server. MapPath (@ "Uploads ");
// If the path does not exist, create
If (System. IO. Directory. Exists (Path) = false)
{
System. IO. Directory. CreateDirectory (Path );
}
// Combined path, file. GetName () to get the file name
Path = Path + "/" + file. GetName (). ToString ();
// Save
File. SaveAs (Path, true );
}
}
Add using Telerik. WebControls to the code above;
2. register the component at the top of the front-end code
[Html]
<% @ Register TagPrefix = "telerik" Namespace = "Telerik. QuickStart" Assembly = "Telerik. QuickStart" %>
<% @ Register TagPrefix = "radU" Namespace = "Telerik. WebControls" Assembly = "RadUpload. Net2" %
3. Html page
[Html]
<Radu: radprogressmanager id = "Radprogressmanager1" Width = "100%" runat = "server" Height = "37px"/>
<Radu: radprogressarea id = "progressArea1" Width = "100%" runat = "server"> </radu: radprogressarea>
<Asp: FileUpload ID = "FileUpload1" runat = "server"/>
<Asp: Button ID = "btnSave" runat = "server" Text = "Button" OnClick = "btnSave_Click"/>
4. The reference DLL is RadUpload. Net2.dll and Telerik. QuickStart. dll. RadUpload. Net2.xml are all in the BIN directory.
5. webconfig Configuration
[Html]
<HttpModules>
<Add name = "RadUploadModule" type = "Telerik. WebControls. RadUploadHttpModule, RadUpload. Net2"/>
</HttpModules>
<HttpHandlers>
<Add verb = "*" path = "Telerik. RadUploadProgressHandler. aspx" type = "Telerik. WebControls. RadUploadProgressHandler, RadUpload. Net2"> </add>
</HttpHandlers>
<! -- HttpRuntime must be configured here; otherwise, DNSerror is reported, but not uploaded. -->
<HttpRuntime maxRequestLength = "2097151" executionTimeout = "3600"/>
From my independent blog 90 boys share network, DEMO: http://www.bkjia.com/uploadfile/2012/0607/20120607110901476.zip
From Share Network-shi's blog