Dimac Upload.NET is a complete file upload suite that allows you to upload big files as well as displaying a progress bar while uploading. The library also contains download features for sending files to the clients.
To enable Upload.NET on a website you have to perform the following steps:
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="upload" type="Dimac.Upload.Configuration.UploadConfigSectionHandler, Dimac.Upload" /> </configSections> <upload defaultEncoding="utf-8" maxUploadSize="0" uploadBufferSize="65536" storageProvider="memory" fileStorageProviderPath="" downloadBufferSize="65536" /> <system.web> <httpModules> <add name="UploadModule" type="Dimac.Upload.UploadModule, Dimac.Upload" /> </httpModules> <!-- your other settings here --> </system.web> </configuration>You can read more about the configuration settings here.
Once you have performed the two steps above Dimac Upload.NET will handle all requests that matches the following critierias:
Please note that, you have to supply a uid value on the querystring. The value you supply must be a globally unique string. The uid is used internally to separate the different upload requests from each other.
Here's an example of a valid form that will be handled by Upload.NET:
<%@Page Language="C#" %> <html> <body> <form enctype="multipart/form-data" method="post" action="upload.aspx?uid=<%= Guid.NewGuid().ToString() %>"> <input type="file" name="theFile" /> <input type="submit" /> </form> </body> </html>
Here's an example of a page that handles the posted files:
<%@Page Language="C#" %>
<%@Import Namespace="Dimac.Upload" %>
<html>
<body>
<%
UploadSession session = new UploadSession();
if ( session.IsUploadRequest )
{
Response.Write( "<b>File upload request</b><br>" );
foreach ( IPostedFile file in session.Files )
{
string filename = file.SaveUnique( Server.MapPath( "upload.tmp" ) );
Response.Write( "File saved: " + filename + "<br>" );
}
}
else
{
Response.Write( "No file upload request." );
}
%>
</body>
</html>
Note! You can find more example code in your Upload.NET install directory.
First off you have to perform step 1 listed in the Upload Quickstart section.
This example shows how you use Upload.NET for sending files to the client.
<%@Page Language="C#" %> <%@Import Namespace="Dimac.Upload" %> <% Download download = new Download(); download.SendFile( Server.MapPath( "image.gif" ), "my_hovercraft_is_full_of_eels.gif" ); %>