ASPUploader v1.00: Documentation

ItemValue
Version:v1.00
Author:JS Greenwood
Date:04-Feb-2001

Introduction

One of the problems that has plagued ASP (from versions 1.0 to 3.0) has been the lack of an intrinsic way of file uploading. Although there are many upload utilities already available, the licensing costs either tend to be expensive (as these licenses are regularly per-server or per-site), or they are inefficient as they are written as VBScript code. There are utilities that are free, but I thought I'd write my own - firstly as there's only a few hundred lines of code to it, and secondly as there are features missing from many of the uploaders available.

The biggest problem with writing an Uploader is that it invalidates the Request.Form() object, meaning that simple call to Request.Form.Item("txtMyTextbox") will not work. To get round this problem, not only does this file uploader recreate the Form collection in much the same way as other Uploaders, it also adds references to the other collections (QueryString(), ServerVariables(), etc.) to its own object-model. This makes the integration of the uploader into exist code very simple; declaring a variable of "objRequest" on a page, and setting it to an instance of the uploader means that all that then remains to be done is a global replace in the script file of Request. with objRequest..

Usage

As described above, usage of the ASPUploader object is almost identical to that of the intrinsic Request object. As long as the object is instanced before a call is made to Request.Form, then it will automatically populate its own collections:

  • QueryString
  • Form
  • Cookies
  • ClientCertificate
  • ServerVariables
  • Files

As can be seen, the only difference is the addition of the Files collection. Other than these collections, there is only one other method:

  • Item() - This method simulates the Request.Item() method, checking each of the collections (except for Files) for the specified key.

The Items of the Files collection are classes of the type File. The members of this class are as follows:

PropertyDescription
NameThe name of the field on the form
ContentTypeThe MIME type of the file uploaded
FileNameThe name of the file uploaded
BlobThe binary data of the file - returned as a variant
FileSizeThe size of the file in bytes
FunctionDescription
Save Takes the path to save the file to as an input parameter, and returns the boolean result of saving the file to disk. If no path is passed through, then the file is saved to the current folder. If a path is passed through that contains a valid folder location, but no filename, then the filename of the original file will be used. If a full path and filename is passed through, then the file will be saved with that name.

As the default IIS user (IUSR_MachineName) only has guest priveleges, it should be ensured that write-permission is explicitly given to the folders where files are to be saved to.

Installation

Installation of the ASPUploader is very simple - the COM object simply requires registering on the desired web server(s). To do this, select Run from the Start Menu, and type:
  regvr32 FullFilename
Where FullFilename is the full path to the DLL, such as "C:\Components\ASPUploader.dll".