Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems

 

Chili!Upload (File Upload) Component

The Chili!Upload component enables users to save files uploaded by site visitors to the server.

Chili!Upload Registry Settings

The component does not use registry settings.

Chili!Upload Syntax

The Chili!Upload component is registered with the ProgId of "Chili.Upload.1." The following VBScript excerpt creates an instance of the control.

Set report = Server.CreateObject( "Chili.Upload.1" )

Chili!Upload Properties

The Chili!Upload component exposes the following properties:

·   AllowOverwrite  

·   SizeLimit   

·   FileSize

·   SourceFileName  

·   SourceFileExtension  

Chili!Upload AllowOverwrite Property (Read /Write)

The AllowOverwrite property determines whether the component overwrites existing files saved with the same absolute path name as the uploaded file.

Chili!Upload SizeLimit Property (Read/Write)

The SizeLimit property sets the maximum file size in bytes of uploaded files.

Chili!Upload FileSize Property (Read Only)

The FileSize property indicates the size in bytes of the uploaded file.

Chili!Upload SourceFileName Property (Read Only)

The SourceFileName property indicates the file name of the uploaded file.

Chili!Upload SourceFileExtension Property (Read Only)

The SourceFileExtension property indicates the file extension of the uploaded file.

Chili!Upload Methods

The Chili!Upload component exposes the following method:

·   SaveToFile

Chili!Upload SaveToFile Method

The SaveToFile method saves the uploaded file to the location specified by the absolute path name provided by the user.

Chili!Upload SaveToFile Arguments

Path

The absolute path name for the file, which specifies where it is to be saved.

Example:

The following script uploads a file:

<FORM ACTION="fileupld.asp" METHOD="POST" ENCTYPE="multipart/form-data">

<INPUT TYPE="FILE" NAME="FILE">

<INPUT TYPE="SUBMIT" VALUE="Send">

</FORM>

The following fileupld.asp script processes the upload:

<%

Response.Expires = 0

Set fbase = Server.CreateObject("Chili.Upload.1")

fbase.SizeLimit = 10000

fbase.SaveToFile("/opt/datafiles/test.dat")

%>

Done writing <%=fbase.FileSize%> bytes from user file <%=fbase.SourceFileName%> (of type <%=fbase.SourceFileExtension%>)

Note

In a shared Web hosting environment, such as with an Internet Service Provider, you might not know the directory structure above the document root for your virtual host. In this situation, you cannot specify an absolute path name for the file, so you must use the Server.mapPath directive instead. The following example saves the uploaded file to the document root of the virtual host:

<%

Response.Expires = 0

Set fbase = Server.CreateObject("Chili.Upload.1")

fbase.SizeLimit = 10000

fbase.SaveToFile("Server.mapPath("/") & "/" & "test.dat")

%>

Done writing <%=fbase.FileSize%> bytes from user file <%=fbase.SourceFileName%> (of type <%=fbase.SourceFileExtension%>)

Copyright 2002 Sun Microsystems, Inc. All rights reserved. Legal Notice.