Go to AspUpload.com Web Site

AspUpload 2.0

User Manual

Copyright (c) 1998 - 2000 Persits Software, Inc.

Introduction What's New in Version 2.0
System Requirements
Windows 2000 and IIS 5.0,  or
Windows NT 4.0 and IIS 3.0/IIS 4.0, or
Windows 95/98 and Personal Web Server with ASP support.
About Code Samples
All the code samples mentioned in this manual, and many others not mentioned, can be found in the \Samples sub-directory of the AspUpload installation. A complete index of code samples can be found in the file \Samples\SAMPLE_INDEX.HTM. The AspUpload Setup program created the virtual folder /AspUpload on top of the \Samples directory so that you can run the sample files with your browser using URLs of the type http://localhost/AspUpload/Test1.asp.

All database-related code samples were tested against a SQL Server database that can be re-created on your system by running the SQL script \Database\CreateTables.sql. All non-transactional samples will also work against a MS Access database located in the file \Database\ImageDB.mdb.

A complete description of the AspUpload object properties and methods can be found in the file ObjectReference.htm.

Getting Started Working with FILES and FORM Collections Setting a Limit on File Size Forcing Unique File Names Manipulating File Attributes and Access Control Lists Moving, Copying, Renaming and Deleting Files Saving Files to a Database Uploading To Memory (new in AspUpload 2.0)
If the ultimate destination of uploaded files is a database, you may consider using uploads to memory rather than hard drive for better performance and security. To use this feature, you must call Upload.SaveToMemory instead of Upload.Save <path>. The differene betoween the two methods is that the former does not save files to the hard drive. It does, however, create both Files and Form collections in memory. An uploaded file can be accessed via the File.Binary property if you wish to save it to the database using ADO, or File.SaveAs method if you want to save it on hard drive under a certain  name. Here is an example:

<%
Set Upload = Server.CreateObject("Persits.Upload.1")
' ensure a unique name when calling File.SaveAs
Upload.OverwriteFiles = False
Count = Upload.SaveToMemory

If Count = 1 Then ' 1 file uploaded
    Set File = Upload.Files(1)

  ' retrieve destination file name from a HIDDEN form item
    Path = "c:\upload\" & Upload.Form("Filename")
    ' Side effect: SaveAs sets changes File.Path property to a new value.
    File.SaveAs Path
    Response.Write "File was saved as " & File.Path
Else
    Response.Write "No files were uploaded."
End If
%>

Uploading to memory is demonstrated in the code samples UploadScript8.asp and UploadScript11.asp.

Image Size and Type Extraction (new in AspUpload 2.0)
AspUpload 2.0 is capable of obtaining image size information from GIF, JPEG and BMP files via the properties UploadedFile.ImageWidth and UploadedFile.ImageHeight. You can use these properties to limit the size of uploaded images. To determine the type of an uploaded image, you may use the property UploadedFile.ImageType which returns the strings "GIF", "JPG" or "BMP" for GIF, JPEG and BMP files, respectively. If an uploaded file is not an image or its type cannot be determined, this property returns the string "UNKNOWN". The following example demonstrates the usage of these properties (another example can be found in the sample file UploadScript7.asp):

<%
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.Save "c:\upload"
For Each File in Upload.Files

If File.ImageType <> "GIF" and File.ImageType <> "JPG" Then
  Response.Write "GIF or JPG files only please!"
  Exit For
End If

If File.ImageWidth > 150 Then
  Response.Write "Image width cannot exceed 150 pixels."
  Exit For
End If

If File.ImageHeight > 200 Then
  Response.Write "Image height cannot exceed 200 pixels."
  Exit For
End If

Next
%>
User Account Impersonation
By default, ASP scripts run under the security context of the "Anonymous" user account IUSR_machinename. This user account usually has very few permissions and if your script is uploading files to a remote machine you are likely to receive the error "Access is denied." To overcome this problem, you can use the LogonUser method which impersonates an arbitrary user account with sufficient permissions. This method accepts three parameters: a domain name, username and password. Once a successful call to the LogonUser method is made, the rest of the script on that ASP page will run under the security context of the specified user account. For example,

<%
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.LogonUser "mydomain", "Administrator", "xxxxxxxxx"
' Upload to a remote drive
Count = Upload.Save("\\someserver\cdrive\upload")
%>

If an empty string is specified for the domain name, the local machine will be used to validate the username and password.  If your virtual directory has the "Run in separate memory space" option checked, the current user (IUSR_xxx) must have the "Act as part of the operating system" privilege or you will get the error "Required Privilege not held by the client." The usage of the LogonUser method is demonstrated in the code sample UploadScript12.asp.

Preserving "Last Modified" Date/Time Information of Uploaded Files
Currently, browsers do not send the "Last Modified" information along with the files being uploaded as it is not part of the RFC-1867 specification, so if you use form-based uploading the file dates cannot be preserved. However, if you use the Persits Software client upload tools XUpload ActiveX control or JUpload Java applet (the latter is currently under development) the files' dates can be preserved as these tools do send the files' "Last Modified" information to the server. A custom MIME header, X-File-Date, is used as follows: X-File-Date: Wkd Mon DD HH:MM:SS YYYY. The time is converted to Greenwich Meridian Time (GMT) to account for possible time difference between the client and server machines. For example:

X-File-Date: Sun May 01 20:27:01 1994

To capture and use this information with AspUpload, simply set the PreserveFileTime property to True before calling Upload.Save, as follows:

Upload.PreserveFileTime = True

Encryption Support
Starting with build 1.4.0.2, AspUpload is capable of encrypting uploaded files, thus making your Web-based file management system truly secure. This functionality requires AspEncrypt, a cryptographic component from Persits Software, Inc. To learn how to make file uploading and downloading encryption-enabled, and to download your free trial copy of AspEncrypt, visit the AspEncrypt.com web site at www.aspencrypt.com/task_upload.html.
Complimentary Features: Directory Listing, Downloading, and ActiveX Registration Disabling Advanced Features in a Web-Hosting Environment Where to Get More Help
For pricing and ordering information, latest news and a live demo, please visit the AspUpload web site at http://www.aspupload.com. For technical support please write to support@aspupload.com. For general and sales inquiries write to info@aspupload.com.