Upload a File


The following example uploads a file from an HTML form to a Web server. SoftArtisans FileUpEE processes the upload on the server.

The HTML form submitting the file must contain,

To allow file uploads, NTFS permissions must be set appropriately for FileUpEE's temporary and destination directories. For more information, see Security Considerations.
  • The <form> tag attribute ENCTYPE="multipart/form-data".
  • An <input type="file"> tag, including a <name> attribute.

In the FileUpEE script, the following lines process the upload request, and save the uploaded file:

  • Set oFileUpEE = Server.CreateObject("SoftArtisans.FileUpEE")
    Creates an instance of FileUpEE.

  • oFileUpEE.TransferStage = saWebServer
    Specifies the stage of an upload, which may be either Web server or file server. Always set this property. Set TransferStage immediately after creating an instance of FileUpEE.

  • oFileUpEE.ProcessRequest Request, False, False
    Passes the Request object to FileUpEE. This instructs FileUpEE to read the upload request and populate the Files and Form collections.

  • oFileUpEE.DestinationDirectory = Server.MapPath(Application("sampleroot") & "/temp")
    Sets the destination directory for the uploaded file.

  • oFileUpEE.Files("myFile").DestinationFileName = oFileUpEE.Files("myFile").ClientFileName
    Sets the destination file name to the file's original name.

  • oFileUpEE.Files("myFile").Save
    Saves the file.
Avoid Errors by Using Typelibs

In ASP, Typelibs provide quick and convenient access to constants associated with a particular object. The server script in this example includes FileUpEE's TypeLib because the script uses constants (e.g, saAllProcessed). The UUID attribute specifies FileUpEE's unique identifier.

	<!--METADATA TYPE="TypeLib" UUID="{6B16F98B-015D-417C-9753-74C0404EBC37}" -->

Example: A Simple Upload

A 100K size limit has been set on upload samples.

Important: The example saves the upload to the folder FileUpEE\doc-samples\samples\temp. The IUSR_MACHINENAME or authenticated user account must have Read, Write, and Modify access to this folder.

To run the example:

  1. Click the link Run sample.


  2. Browse to select a file to upload, and click Upload.


Upload a File

[View Source]

Top


Copyright © 2003, SoftArtisans, Inc.