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 |
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
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.
FileCount = objFileUpload.Count
The Count property returns the number of files in the item
list.
Integer
Set File = objFileUpload.Item(n)
The item property is returns un array of FileObj
objects.
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.
objFileObj.Save
Execute this method for write the file to the disk.
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.
String
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.
String