|
The Chili!Upload component enables users to save files uploaded by site visitors to the server.
The component does not use registry settings.
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" )
The Chili!Upload component exposes the following properties:
· AllowOverwrite
· SizeLimit
· FileSize
· SourceFileName
· SourceFileExtension
The AllowOverwrite property determines whether the component overwrites existing files saved with the same absolute path name as the uploaded file.
The SizeLimit property sets the maximum file size in bytes of uploaded files.
The FileSize property indicates the size in bytes of the uploaded file.
The SourceFileName property indicates the file name of the uploaded file.
The SourceFileExtension property indicates the file extension of the uploaded file.
The Chili!Upload component exposes the following method:
· SaveToFile
The SaveToFile method saves the uploaded file to the location specified by the absolute path name provided by the user.
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.