Go to AspUpload.com Web Site

AspUpload 2.1

User Manual

See Also: Object Reference

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

Introduction What's New in Version 2.1
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.
Installation Procedure
To install AspUpload, download and run the setup application aspupload.exe . The aspupload.exe setup will install both the AspUpload component (aspupload.dll) and all the documentation into a directory on your hard drive that you specify during installation. Typically, it is c:\Program Files\Persits Software\AspUpload, but it can be any other directory. The install routine will automatically register the component DLL on your machine. During installation, your IIS-related services will be shut down and restarted.

If you need to move the AspUpload component to another server, it is sufficient to copy the file aspupload.dll (located under the \Bin subdirectory of the installation) to the other machine and register it there using the regsvr32 command-line utility. You may copy the file aspupload.dll to any folder on the second server's hard drive, e.g. c:\winnt\system32. To register the dll, run the MS DOS prompt and type the command

c:\>regsvr32 c:\winnt\system32\aspupload.dll

You should specify another path if necessary. If this server is already running an older version of AspUpload, you must remove it from memory prior to registering a newer version by shutting down all IIS services. To do that, type the following command at your DOS prompt:

c:\>net stop iisadmin /y

To bring the WWW service back up, type the command

c:\>net start w3svc

Other IIS services (such as FTP, SMTP, NNTP, Site Server, etc) can be restarted from the Services control panel.

Once you purchase a registered copy of AspUpload, you will have to repeat the installation procedure on the server. AspUpload does not use registration keys, the registered version of the DLL has to be installed over an evaluation version. The old version does not need to be un-registered or un-installed. Make sure IIS services get restarted during re-installation to remove the evaluation version from memory.

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
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 difference between 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 (improved in AspUpload 2.1)
AspUpload 2.1 is capable of obtaining image size information from GIF, JPEG, PNG 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", "PNG" or "BMP" for GIF, JPEG, PNG 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 "A required privilege not held by the client."

On Windows 2000/IIS5, you must set the "Application Protection" option to Low (IIS Process) on your virtual directory to avoid the error "A 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
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
If you are having problems with AspUpload, check with our searchable database of technical articles at SUPPORT.PERSITS.COM. If none of the articles helped, please contact us at support@aspupload.com.

For pricing and ordering information, latest news and a live demo, please visit the AspUpload web site at http://www.aspupload.com. For general and sales inquiries write to info@aspupload.com.