This example shows how to upload two image files.



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

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


We create an XForm object and specify some preferences. By default ABCUpload will throw an error if you try to overwrite a file that already exists. This is done for safety reasons but is not always the behavior we desire. To force ABCUpload to overwrite any files that already exist we set the Overwrite property of the XForm object to True.

As a shortcut we create a reference to the image field and store it in a variable called theField. Now we can use this as shorthand to check each of the fields. Each field is checked. If a file has been uploaded then it is saved out. This avoids saving zero length files in cases where no file was uploaded by the client.

Note that we preserve the original name of the file as uploaded from the client. The FileName property of the XField object is a URL safe version of the original client file name.

<% @Language="VBScript" %>
Set theForm = Server.CreateObject("ABCUpload4.XForm")
theForm.Overwrite = True
Set theField = theForm.Files("image1")
If theField.FileExists Then theField.Save theField.FileName
Set theField = theForm.Files("image2")
If theField.FileExists Then theField.Save theField.FileName
Images uploaded...