[about] [purchase] [installation] [technical support] [examples] [constants] [properties] [methods] |
About AspFTP
AspFTP is an ActiveX/OLE component that provides access to the standard FTP commands. The Microsoft Windows WININET.DLL (ships with Internet Explorer) is required for AspFTP to function correctly. For more information on FTP, refer to RFC959 - File Transfer Protocol (FTP).
Features include:
- Get (receive) Files
- Put (send) Files
- Delete Files
- Rename Directories/Files
- List Directory Contents
- Get/Change Current Directory
- Create/Delete Directories
- Incrementally Write To Files
- Read Files
Purchasing AspFTP back to top
AspFTP is currently FREE. The registration process is only used to get an approximate number of users and to provide you with upgrade notifications.AspFTP Installation back to top
- Move the DLL into a directory.
- Register the component on the system:
a. Change to the directory where you moved the DLL.
b. Enter: regsvr32 aspftp.dll
c. You should receive a "DLLRegisterServer in aspftp.dll succeeded" message.NOTE: Use the version of regsvr32.exe that is included with AspFTP or the version that came with Microsoft ASP.
Technical Support back to top
If you require technical support please send complete details about the problem you are having to support@niblack.com. Include the version of AspFTP you are using, any error messages, sample code snippets that demonstrate the problem, information about the hosting environment etc. For example, if you are using ASP to host the component please let me know what version of IIS and ASP you are running (and if you have installed any of the HotFixes). The more information you can provide in your request for help, the faster your problems can be resolved.
Examples back to top
The following code demonstrates how to use AspFTP's bQGetFile method. In this example, Wally would like to receive dirmap.txt file from ftp.microsoft.com
<%@ LANGUAGE=VBScript %> <!--#Include File="aspftp2.inc"--> <% 'check to see if user submitted form If Request.Form("GetIt") <> "" Then Dim objFTP Dim strMsg 'create reference to object Set objFTP = Server.CreateObject("NIBLACK.ASPFTP") 'connection worked...now get the file If objFTP.bQGetFile("ftp.microsoft.com","anonymous","wally@wallyworld.com","dirmap.txt", "c:\dirmap.txt",TRANSFER_TYPE_ASCII,True) Then 'get was successful strMsg = "Get Successful!" Else 'get failed...let user know strMsg = "Get Failed: " & objFTP.sError End If 'clean up... Set objFTP = Nothing Else 'default return msg strMsg = "" End If %> <html> <body> This example uses the "quick" Get method (bQGetFile). All parameters required for receiving a file are explicitly defined in the ASP code.<br> <hr> <br> <%If strMsg <> "" Then%> Return Message: <%=strMsg%><br> <hr> <br> <%End If%> <form action="AspFTP2_QGet.asp" method="post"> <input type="submit" name="GetIt" value="Get File"> </form> </body> </html>The following code demonstrates how to use AspFTP's bQGetFile method. In this example, the user provides all the parameters required for the method.
<%@ LANGUAGE=VBScript %> <!--#Include File="aspftp2.inc"--> <% 'check to see if user submitted form If Request.Form("GetIt") <> "" Then Dim objFTP Dim strMsg 'create reference to object Set objFTP = Server.CreateObject("NIBLACK.ASPFTP") 'connection worked...now get the file If objFTP.bQGetFile(Request.Form("Server"),Request.Form("User_ID"),Request.Form("Password"),Request.Form("Remote_File"), Request.Form("Local_File"),Request.Form("Transfer_Type"),Request.Form("OverWrite")) Then 'get was successful strMsg = "Get Successful!" Else 'get failed...let user know strMsg = "Get Failed: " & objFTP.sError End If 'clean up... Set objFTP = Nothing Else 'default return msg strMsg = "" End If %> <html> <body> This example uses the "quick" Get method (bQGetFile). All parameters required for receiving a file are entered by the user in the form below.<br> <hr> <br> <%If strMsg <> "" Then%> Return Message: <%=strMsg%><br> <hr> <br> <%End If%> <form action="AspFTP2_QGet_form.asp" method="post"> <table border="0" cellspacing="10"> <tr> <td>Server/Host Name:</td> <td><input name="Server" size="25"></td> </tr><tr> <td>User ID:</td> <td><input name="User_ID" size="25"></td> </tr><tr> <td>Password:</td> <td><input name="Password" size="25"></td> </tr><tr> <td>Remote File Name:</td> <td><input name="Remote_File" size="25"></td> </tr><tr> <td>Local File Name:</td> <td><input name="Local_File" size="25"></td> </tr><tr> <td>File Type:</td> <td><select name="Transfer_Type"> <option value="1">ASCII</option> <option value="2">Binary</option> </select></td> </tr><tr> <td>Overwrite Existing File?</td> <td><input name="OverWrite" type="radio" value="True" checked>True <input name="OverWrite" type="radio" value="False">False</td> </tr><tr> <td colspan="2" align="center"><input type="submit" name="GetIt" value="Get File"></td> </tr> </table> </form> </body> </html>AspFTP Constants back to top
Constant Description ACCESS_TYPE_PRECONFIG = 0
ACCESS_TYPE_DIRECT = 1
ACCESS_TYPE_PROXY = 2Used to specify the type of connection to use for an FTP session. Access by the lAccessType property. TRANSFER_TYPE_ASCII = 1
TRANSFER_TYPE_BINARY = 2Used to specify the type of transfer to use when sending, receiving, reading, or writing files. Access by the lTransferType property. FILE_ACCESS_WRITE = 1
FILE_ACCESS_READ = 2Used to specify the type of access to use when opening a file with the bOpenFile method. Access by the lFileAccess property. ATTRIBUTE_READONLY = 1
ATTRIBUTE_HIDDEN = 2
ATTRIBUTE_SYSTEM = 4
ATTRIBUTE_DIRECTORY = 16
ATTRIBUTE_ARCHIVE = 32
ATTRIBUTE_NORMAL = 128
ATTRIBUTE_TEMPORARY = 256
ATTRIBUTE_COMPRESSED = 2048
ATTRIBUTE_OFFLINE = 4096Used to specify the type of items to return when using the bGetDir and sListDir methods. You can use any combination of these attribute flags.
AspFTP Properties back to top
Property Description bOverWrite Determines if an existing local file is replaced during calls to bGetFile and bQGetFile. By default, bOverWrite is True. Valid values:
- True
- False
Example:
objFTP.bOverWrite = True
bPassiveMode Determines if "passive" ftp mode is used. By default, bPassiveMode is True. Valid values:
- True
- False
Example:
objFTP.bPassiveMode = True
lAccessType Connection method to use for FTP session. If Preconfig is specified, AspFTP retrieves the proxy or direct configuration from the Windows Registry. If Direct, all server names are resolved locally. If Proxy, AspFTP passes requests to the proxy specified unless, a proxy bypass list is supplied and the name to be resolved bypasses the proxy. By default, lAccessType is ACCESS_TYPE_DIRECT. Valid values:
- 0 = ACCESS_TYPE_PRECONFIG = Preconfig
- 1 = ACCESS_TYPE_DIRECT = Direct
- 3 = ACCESS_TYPE_PROXY = Proxy
Example:
objFTP.lAccessType = ACCESS_TYPE_DIRECT
lErrorNum
(read only)Returns the last error number. If no error exists, 0 is returned. Example:
lngLastError = objFTP.lErrorNum
lFileAccess Access allowed when using the bOpenFile method. To allowing read access, specify FILE_ACCESS_READ. For writing, specify FILE_ACCESS_WRITE. A file can not be opened with both read and write access. By default, lFileAccess is FILE_ACCESS_WRITE. Valid values:
- 1 = FILE_ACCESS_WRITE
- 2 = FILE_ACCESS_READ
Example:
objFTP.lFileAccess = FILE_ACCESS_WRITE
lTransferType Transfer method to use during calls to bGetFile, bOpenFile, bPutFile, bQGetFile, bQPutFile. By default, lTransferType is TRANSFER_TYPE_ASCII. Valid values:
- 1 = TRANSFER_TYPE_ASCII = ASCII
- 2 = TRANSFER_TYPE_BINARY = Binary
Example:
objFTP.lTransferType = TRANSFER_TYPE_ASCII
sError
(read only)Returns the last error message. If no error exists, "0:" is returned. Example:
sLastError = objFTP.sError
sErrorDesc
(read only)Returns the last error description. If no error exists, Null is returned. Example:
sLastErrorDesc = objFTP.sErrorDesc
sPassword Specifies password to use during an FTP session. By default, sPassword is Null. Example:
objFTP.sPassword = "password"
sProxyBypass Specifies the Proxy Bypass string to use during an FTP session. This property is only used when lAccessType <> ACCESS_TYPE_DIRECT. By default, sProxyBypass is Null. Example:
objFTP.sProxyBypass = "ms*"
sProxyName Specifies name of the proxy server (or servers) to use during an FTP session. This property is only used when lAccessType <> ACCESS_TYPE_DIRECT. By default, sProxyName is Null. Example:
objFTP.sProxyName = "ftp=ftp://ftp_proxy_name:21"
sServerName Specifies the name of the FTP server (host name or IP address) to use during an FTP session. By default, sServerName is Null. Example:
objFTP.sServerName = "ftp.microsoft.com"
sUserID Specifies the User ID/Name to use during an FTP session. By default, sUserID is "anonymous". Example:
objFTP.sUserID = "anonymous"
AspFTP Methods back to top
Method Parameters Return Value Description bCloseFile None True or False based upon success or failure. The bCloseFile method attempts to close a file that was opened for reading or writing using the bOpenFile method. bConnect None True or False based upon success or failure. The bConnect method attempts to connect to the server specified by the sServerName property using the sUserID and sPassword properties for the user name and password, respectively. bDeleteFile strFile True or False based upon success or failure. The bDeleteFile method attempts to delete the file specified in strFile from the server specified by the sServerName property using the sUserID and sPassword properties for the user name and password, respectively. See bQDeleteFile for the "quick" method.
bDisconnect None True or False based upon success or failure. The bDisconnect method attempts to disconnect and end any FTP session currently running. bGetDir strDir (optional)
intType (optional)True or False based upon success or failure. The bGetDir method attempts to enumerate the directory contents specified in strDir. If strDir is not provided, the current directory is enumerated. bGetFile strSourceFile
strTargetFileTrue or False based upon success or failure. The bGetFile method attempts to Get (receive) the file specified in strSourceFile from the server specified by the sServerName property using the sUserID and sPassword properties for the user name and password, respectively. strTargetFile specifies name of the file to create on the local system. If strTargetFile already exists and bOverWrite is False, an error occurs.
See bQGetFile for the "quick" method.
bMakeDir strDir True or False based upon success or failure. The bMakeDir method attempts to create the directory specified in strDir on the server specified by the sServerName property using the sUserID and sPassword properties for the user name and password, respectively. See bQMakeDir for the "quick" method.
bOpenFile strFileName True or False based upon success or failure. The bOpenFile method attempts to open the file specified in strFileName on the the server specified by the sServerName> property using the sUserID and sPassword properties for the user name and password, respectively. The property lFileAccess specifies how the file is accessed.
bPutFile strSourceFile
strTargetFileTrue or False based upon success or failure. The bPutFile method attempts to Put (send) the file specified in strSourceFile to the server specified by the sServerName property using the sUserID and sPassword properties for the user name and password, respectively. strTargetFile specifies name of the file to create on the remote system. If strTargetFile already exists, the existing file is replaced.
See bQPutFile for the "quick" method.
bQDeleteFile strServerName
strUserID
strPassword
strFileTrue or False based upon success or failure. The bQDeleteFile method attempts to delete the file specified in strFile from the server specified in strServerName using the values in strUserID and strPassword for the user name and password, respectively. This method is the equivilent to bDeleteFile.
bQGetFile strServerName
strUserID
strPassword
strSourceFile
strTargetFile
lngTransferType
blnOverWriteTrue or False based upon success or failure. The bQGetFile method attempts to Get (receive) the file specified in strSourceFile from the server specified in strServerName using strUserID and strPassword for the user name and password, respectively. strTargetFile specifies the name of the file to create on the local system.
lngTransferType specifies if the file is to be received in ASCII format or Binary format. lngTransferType should be set to 1 for ASCII files and 2 for binary files.
blnOverWrite specifies if the file received over writes or replaces an existing file of the same name. If blnOverWrite = True, then any existing files are replaced. If blnOverWrite is False and a file of the same name already exists, an error will occur.
This method is equivilent to bGetFile.
bQMakeDir strServerName
strUserID
strPassword
strDirTrue or False based upon success or failure. The bQMakeDir method attempts to create directory specified in strDir on the server specified in strServerName using strUserID and strPassword for the user name and password, respectively. This method is equivilent to bMakeDir.
bQPutFile strServerName
strUserID
strPassword
strSourceFile
strTargetFile
lngTransferTypeTrue or False based upon success or failure. The bQPutFile method attempts to Put (send) the file specified in strSourceFile to the server specified in strServerName using strUserID and strPassword for the user name and password, respectively. strTargetFile specifies the name of the file to create on the remote system. If strTargetFile already exists, the existing file is replaced.
lngTransferType specifies if the file is to be sent in ASCII format or Binary format. lngTransferType should be set to 1 for ASCII files and 2 for binary files.
This method is equivilent to bPutFile.
bQRemoveDir strServerName
strUserID
strPassword
strDirTrue or False based upon success or failure. The bQRemoveDir method attempts to remove the directory specified in strDir from the server specified in strServerName using strUserID and strPassword for the user name and password, respectively. If strDir is not empty, an error occurs. This method is equivilent to bRemoveDir.
bQRename strServerName
strUserID
strPassword
strCurrentName
strNewNameTrue or False based upon success or failure. The bQRename method attempts to rename the directory or file specified in strCurrentName to strNewName on the server specified in strServerName using strUserID and strPassword for the user name and password, respectively. This method is equivilent to bRename.
bRemoveDir strDir True or False based upon success or failure. The bRemoveDir method attempts to remove the directory specified in strDir from the server specified by the sServername property using the sUserID and sPassword properties for the user name and password, respectively. If strDir is not empty, an error occurs. See bQRemoveDir for the "quick" method.
bRename strCurrentName
strNewNameTrue or False based upon success or failure. The bRename method attempts to rename the directory or file specified in strCurrentName to strNewName on the server specified by the sServername property using the sUserID and sPassword properties for the user name and password, respectively. See bQRename for the "quick" method.
bSetCurrentDir strDirName True or False based upon success or failure. The bSetCurrentDir method attempts to make the directory specified in strDirName the current directory on the server specified by the sServername property using the sUserID and sPassword properties for the user name and password, respectively. bWriteFile strData True or False based upon success or failure. The bWriteFile method attempts to write to the file opened by the bOpenFile method. You can write to a file opened by the bOpenFile method until you close the file using the bCloseFile method. Use this method when wanting to write incrementally to a remote file, create a remote file without a local file to send, or you want to provide progress information for writing a file.
lGetDirCount None Number of items. The lGetDirCount method returns the number of items in the current directory collection that was created using the bGetDir method. sConvertCrLf strData Returns strData converted. The sConvertCrLf method converts all occurances of Cr+Lf (Chr$(10)+Chr$(13)) into the HTML linebreak tag (<br>). This is included to provide an easy way to use the directory listing returned from the sListDir method.
sGetCurrentDir None Returns the name of the current directory. The sGetCurrentDir method returns the name of the current directory on the remote system. sGetDirName intItem Returns the name of the item specified in intItem. The sGetDirName method returns the name of the item specified by intItem. This method is used after calling the bGetDir method to enumerate a remote directory.
sListDir strDir (optional)
intType (optional)Returns a ; delimited string of all the items in the directory specified in strDir. The sListDir method returns a semi-colon (;) delimited string of all the items in the directory specified in strDir on the server specified by the sServername property using the sUserID and sPassword properties for the user name and password, respectively. The VBScript Split function or the JScript split method to parse the individual items from the return string.
Alternatively, if you want an HTML compatible directory listing, use the ConvertCrLf method.
sReadFile None Returns the contents of the file specfied in the most recent bOpenFile statement. The sReadFile method attempts to read the contents of the file opened by the bOpenFile method. The ENTIRE file is read and returned. Use this method when wanting to get the contents of a remote file directly into a string.
[about] [purchase] [installation] [technical support] [examples] [constants] [properties] [methods] |
Copyright © 1998 by Jeffrey A. Niblack. All Rights Reserved.