The UploadedFile class holds the information about the uploaded
file. It contains the original names, paths, size and contents of all
the files uploaded. This class can be accessed by calling the UploadedFile
method on an Upload object.
Methods
Properties
Return Values
Methods
Method Signature: void copy([in]String
fullyQualifiedPath, [Optional] boolean overwrite)
This method copies the uploaded file to the another path as specified
by the fully qualified path name in the argument. Overwriting is
by default True, but if overwrite is False, and the file with this name
alredy exists, then this methods fails.
Example: for copying files
Html page:
<HTML>
<HEAD>
<TITLE>Multiple File Upload via iASP_Upload</TITLE>
</HEAD>
<BODY>
<form enctype="multipart/form-data" method="post"
action="sample2.asp">
Enter filename to upload: <input type="file" name="file1"><br>
Enter filename to upload: <input type="file" name="file2"><br>
Enter filename to upload: <input type="file" name="file3"><br>
<input type="submit">
</form>
</BODY>
</HTML>
Script of 'sample2.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
For Each File in obj.Files
File.copy "d:\archive\"
& File.extractFileName, false
Next
%>
Method Signature: void copyVirtual([in]String
VirtualDir, [Optional] boolean overwrite)
This method copies the uploaded file to the virtual directory as specified
by the fully qualified path in the argument. Overwriting is by default
True, but if overwrite is False, and the file with this name alredy exists,
then this methods fails.
Example: copying files in virtual directory
Html page:
<HTML>
<HEAD>
<TITLE>Multiple File Upload via iASP_Upload</TITLE>
</HEAD>
<BODY>
<form enctype="multipart/form-data" method="post"
action="sample2.asp">
Enter filename to upload: <input type="file" name="file1"><br>
Enter filename to upload: <input type="file" name="file2"><br>
Enter filename to upload: <input type="file" name="file3"><br>
<input type="submit">
</form>
</BODY>
</HTML>
Script of 'sample2.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
For Each File in obj.Files
File.copyVirtual
"d:\virDir\" & File.extractFileName, false
Next
%>
Method Signature: void move([in]String
dirName)
This method moves the uploaded file to the another folder on the server
as specified in the argument.
Example: for moving files
Html page:
<HTML>
<HEAD>
<TITLE>Multiple File Upload via iASP_Upload</TITLE>
</HEAD>
<BODY>
<form enctype="multipart/form-data" method="post"
action="sample2.asp">
Enter filename to upload: <input type="file" name="file1"><br>
Enter filename to upload: <input type="file" name="file2"><br>
Enter filename to upload: <input type="file" name="file3"><br>
<input type="submit">
</form>
</BODY>
</HTML>
Script of 'sample2.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
For Each File in obj.Files
File.move "d:\temp2\"
& File.extractFileName
Next
%>
Method Signature: void moveVirtual([in]String
virtualDir)
This method moves the uploaded file to the virtual directory on the server
as specified in the argument.
Example: for moving files in a virtual directory
Html page:
<HTML>
<HEAD>
<TITLE>Multiple File Upload via iASP_Upload</TITLE>
</HEAD>
<BODY>
<form enctype="multipart/form-data" method="post"
action="sample2.asp">
Enter filename to upload: <input type="file" name="file1"><br>
Enter filename to upload: <input type="file" name="file2"><br>
Enter filename to upload: <input type="file" name="file3"><br>
<input type="submit">
</form>
</BODY>
</HTML>
Script of 'sample2.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
For Each File in obj.Files
File.moveVirtual
"d:\virDir\" & File.extractFileName
Next
%>
Method Signature: void delete()
This method deletes the files on the Server. Use this method when
the uploaded files are either saved in the database or are copied to the
desired location, and there is no need for these files on server hard
disk.
Example: deleting files
Html page:
<HTML>
<HEAD>
<TITLE>Multiple File Upload via iASP_Upload</TITLE>
</HEAD>
<BODY>
<form enctype="multipart/form-data" method="post"
action="sample2.asp">
Enter filename to upload: <input type="file" name="file1"><br>
Enter filename to upload: <input type="file" name="file2"><br>
Enter filename to upload: <input type="file" name="file3"><br>
<input type="submit">
</form>
</BODY>
</HTML>
Script of 'sample2.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
'temporary saving
For Each File in obj.Files
File.Copy "d:\archive\"
& File.extractFileName
File.delete
Next
%>
Method Signature: void toDatabase([in]String
connectString, [in]String queryString)
This method saves the browsed files into the database. The connectString
is the proper Connection String in the format "DSN=DSNName;PWD=;UID=;"
for the database, whereas the querystring is the proper insert or update
query to be executed, with one '?' sign, which acts as the place holder
for the file.
Example: saving a database record
Html page:
<HTML>
<HEAD>
<TITLE>Multiple File Save to the DataBase via iASP_Upload</TITLE>
</HEAD>
<BODY>
<form enctype="multipart/form-data" method="post"
action="sample2.asp">
Enter filename to upload: <input type="file" name="file1"><br>
Enter filename to upload: <input type="file" name="file2"><br>
Enter filename to upload: <input type="file" name="file3"><br>
<input type="submit">
</form>
</BODY>
</HTML>
Script of 'sample2.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
count=0
obj.save "c:\temp\"
For Each File in obj.Files
File.toDatabase
"data","insert into Blob(index,BlobF) values(count,?)"
count=count+1
File.delete
Next
%>
Method Signature: String
extractFileName()
This method returns the original name of the file uploaded.
Example: retrieving filenames
Script of 'sample.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
'temporary saving
For Each File in obj.Files
File.Copy "d:\archive\"
& File.extractFileName
File.delete
'deletes the current file
Next
%>
Method Signature: String
extractFolderName()
This method returns the back slash terminated uploaded path of the file.
Example: retrieving folder names
Script of 'sample.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
'temporary saving
For Each File in obj.files
Response.Write
File.extractFolderName
Next
%>
Method Signature: boolean FtpPutFile(String,
String, String, String, String, int)
This method is used to transfer the Local file to the Ftp Server. Use
the following syntax:
FtpPutFile("HostName", "UserName", "Password","RemoteFileName","LocalFileName",Mode)
Argument
|
Description
|
HostName |
Name of the Host Machine where FTP Server runs. |
User Name |
Name of the user to be connected to the FTP Server. |
Password |
It provides security for the users data. It authorizes
to communicate with the FTP Server. |
RemoteFile |
File which is to be stored at the remote side |
LocalFile |
Local file by which the remote file is to be saved. |
Mode |
It has two modes, '1' represents 'ASCII' and
'2' represents 'Binary' mode. Choose any one mode. |
You can write Visual Basic scripts to communicate with the FTP Server.
An object needs to be created to get and put the desired files. Use the
FtpPutFile method to transfer files to the FTP Server:
- Click on the Start button of the window, drag the mouse to Program
and then to Accessories. From Accessories click on the notepad.
- Create Object by using the CreateObject statement:
Set FtpCon = Server.CreateObject(iASPInet.FTP)
- Next, call the method:
FtpCon.FtpPutFile ("HostName","User","Password","Remote
FileName"."LocalFileName",Mode")
Method Signature: long getLastError() : This
method returns the last error that occurred during communication.
Use the getLastError method to get the last error that occurred during
the communication.
- Set the getLastError method:
FtpCon.getLastError
Properties
Property Signature: String getPath()
This is a read-only property. It returns the fully qualified path of
the file on the server.
Example: retrieving the path on the server
Script of 'sample.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
'temporary saving
For Each File in obj.files
Response.Write
File.getPath
Next
%>
Property Signature: String getOriginalPath()
This is a read-only property. It method returns the fully qualified path
of the file on the client.
Example: retrieving the path on a client
Script of 'sample.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
'temporary saving
For Each File in obj.files
Response.Write
File.getOriginalPath
Next
%>
Property Signature: int getOriginalSize()
This is a read-only property that returns the original size of the file
on the client.
Example: for retrieving original file size
Script of 'sample.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
'temporary saving
For Each File in obj.files
Response.Write
File.getOriginalSize
Next
%>
Property Signature: int getSize()
This is a read-only property that returns the uploaded size of the file,
which may be different from the one on the client machine. The file size,
for an upload, can be changed by using setMaxSize
property on Upload object.
Example: for retrieving the uploaded file size
Script of 'sample.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
'temporary saving
For Each File in obj.files
Response.Write
File.getSize
Next
%>
Property Signature: String getName()
This is a read-only property that returns the value of the NAME attribute
of this file's <INPUT TYPE=FILE> tag.
Example: retrieving the NAME attribute
Script of 'sample.asp':
<%
Set obj = Server.CreateObject("Persits.Upload")
obj.save "c:\temp\"
'temporary saving
For Each File in obj.files
Response.Write
File.getName
Next
%>
Errors
Error
|
Constant
|
Description
|
NO_ERROR |
0 |
Represents no error. |
UNKNOWN_HOST |
1 |
HOST is not found. |
USER_CANNOT_LOGIN |
2 |
The given password and login name are not correct. |
REMOTE_FILE_NOT_FOUND |
3 |
File requested by the Get method does not exist at the
remote side. |
LOCAL_FILE_NOT_FOUND |
4 |
Local file is not present. |
INVALID_PATH |
5 |
Given path to Put the file is not valid. |
ACCESS_DENIED |
6 |
Access to Put the file at FTP Server is denied. |
INVALID_MODE |
7 |
The mode is not valid. |
If you require technical support please send complete details about the
problem you are having to support@halcyonsoft.com.
|