Dimac Upload.NET

Getting Started

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.

Upload Quickstart

To enable Upload.NET on a website you have to perform the following steps:

  1. Make sure that Dimac.Upload.dll is in your web applications executable path, i.e. in the "bin"-folder or in the GAC.
  2. Make sure that your web.config contains the follwing:
    <?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.

Upload Code Samples

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.

Download Quickstart

First off you have to perform step 1 listed in the Upload Quickstart section.

Download Code Samples

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" );
%>