Objects, Properties, and Methods

This reference contains property and method information for the File Upload Library objects.
The following table summarizes each object's properties and methods.


Object

Properties

Methods
FileUpload  Count, Directory, Item Upload
FileObj Directory, FileName, Size Save

FileUpload Object

The FileUpload object is a core object of File Upload Library. It has a method Upload, that allows get the files from web browser and, a list of FileObj objects containg the files description.The files aren't written to a disk until you execute the Save  method for each FileObj. Here is an example ASP code:

<%
    'Create the file upload object
    Set fu = Server.CreateObject("AspUtil.FileUpload")

   'Set the default directory where to put the files
    fu.directory = Server.MapPath(".")

    'do upload
    rc = fu.Upload 

   'check completion
    If rc = 0 then

        'loop trough the files
        For n=0 to fu.count-1
            'Get a file object
            Set File = fu.item(n)

            'Shows info
            Response.Write "FileName: " & File.Filename
            Response.Write "Bytes written: " & File.Size
            'You can set a new Directory and new Filename
            'File.Filename = "newname.txt"
            'File.Directory = "c:\newdir"

            'Save the file
            File.Save
        Next
    Else
        'Error in form
        Response.Write "File upload failed. RC: " & rc
    End If
%>

FileUpload.Upload Method

Syntax

objFileUpload.Upload

Execute this method for receive the files from the web browser. On finish, the item property, will contain a list of the files downloaded. At this moment the files are not in the disk yet. To finish upload, execute the save method for each file in the item list.

FileUpload.Count property

Syntax

FileCount = objFileUpload.Count

The Count property returns the number of files in the item list.

Data Type

Integer

FileUpload.Item property

Syntax

Set File = objFileUpload.Item(n)

The item property is returns un array of  FileObj objects.

Data Type

FileObj

 

FileObj Object

The FileObj object represents one file uploaded to web server. Changing the Filename and Directory properties you can specify the final filename and directory and then execute the Save method to write the file to the disk.


FileObj.Save method

Syntax

objFileObj.Save

Execute this method for write the file to the disk.


FileObj.Directory property

Syntax

directory = objFileObj.Directory
objFileObj.Directory = directory

Get/Sets the directory where the file will be written. The default value is taken from Directory property of FileUpload object.

Data Type

String

FileObj.Filename property

Syntax

Filename = objFileObj.Filename
objFileObj.Filename = Filename

Get/Sets the directory where the file will be written. The default value is taken from Directory property of FileUpload object.

Data Type

String