This example uploads two image files to show how to interoperate between ABCUpload and the standard ASP.NET classes. It assumes that minimal configuration settings in the web.config file are implemented.

 

   
HTML
 
imageupload.htm    
     

All we need is a multipart HTML form with two file fields in it. This page submits data to imageupload.asps.

<html>
<body>
<form method="post" action="imageupload.aspx" enctype="multipart/form-data">
<input type="file" name="image1"><br>
<input type="file" name="image2"><br>
<input type="submit" name="submit" value="submit">
</form>
<body>
</html>


   
ASP
 
imageupload.aspx    
     

We create an Upload object and specify some variables. We'll be using one ABCUpload UploadedFile object and one ASP.NET HttpPostedFile object to show how we can use both at the same time. We could reduce the amount of code considerably if we made use of ABCUpload added functionality but the aim for this example is to show how both objects can be used identically.

First we get a reference to our file object by referencing the Files collection within the Upload object. We check that some data has been uploaded and if so we work out a destination file name and then save the file to this location. The code using the standard ASP.NET classes is identical.

[C#]
<%@ Import Namespace="WebSupergoo.ABCUpload6" %>

<%
Upload Upload = new Upload();
UploadedFile theFile1;
HttpPostedFile theFile2;
string thePath;

theFile1 = Upload.Files["image1"];
if (theFile1.ContentLength > 0) {
  thePath = System.IO.Path.GetFileName(theFile1.FileName);
  thePath = Server.MapPath("write/") + thePath;
  theFile1.SaveAs(thePath);
}

theFile2 = Request.Files["image2"];
if (theFile2.ContentLength > 0) {
  thePath = System.IO.Path.GetFileName(theFile2.FileName);
  thePath = Server.MapPath("write/") + thePath;
  theFile2.SaveAs(thePath);
}
%>

<html>
<body>
Images uploaded...
</body>
</html>

[VB]
<%@ Import Namespace="WebSupergoo.ABCUpload6" %>

<%
Dim Upload As Upload = New Upload()
Dim theFile1 As UploadedFile
Dim theFile2 As HttpPostedFile
Dim thePath As String

theFile1 = Upload.Files("image1")
If theFile1.ContentLength > 0 Then
  thePath = System.IO.Path.GetFileName(theFile1.FileName)
  thePath = Server.MapPath("write/") + thePath
  theFile1.SaveAs(thePath)
End If

theFile2 = Request.Files("image2")
If theFile2.ContentLength > 0 Then
  thePath = System.IO.Path.GetFileName(theFile2.FileName)
  thePath = Server.MapPath("write/") + thePath
  theFile2.SaveAs(thePath)
End If
%>

<html>
<body>
Images uploaded...
</body>
</html>