Asp免费FTP组件的用法 Xinsoft,2003-11-02 14:34:55
组件:AspFTP 2.0
下载:http://218.30.124.42/resource/soft/aspftp.dll
下载以后在服务器上注册,这个不用我多说了吧
公用文件:AspFTP2.inc Xinsoft,2003-11-02 14:35:52
AspFTP2.inc
复制代码
- <%
- 'Constants used with the AspFTP ActiveX Component
- ACCESS_TYPE_PRECONFIG = 0
- ACCESS_TYPE_DIRECT = 1
- ACCESS_TYPE_PROXY = 2
- TRANSFER_TYPE_ASCII = 1
- TRANSFER_TYPE_BINARY = 2
- FILE_ACCESS_WRITE = 1
- FILE_ACCESS_READ = 2
- 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 = 4096
- %>
删除文件的例子 Xinsoft,2003-11-02 14:38:57
此帖为对http://www.leadbbs.com/Announce/Announce.asp?BoardID=230&ID=605010的回复
AspFTP2_DeleteFile_form.asp
复制代码
- <%@ LANGUAGE=VBScript %>
- <!--#Include File="aspftp2.inc"-->
- <%
- 'check to see if user submitted form
- If Request.Form("DelIt") <> "" Then
- Dim objFTP
- Dim strMsg
- 'create reference to object
- Set objFTP = Server.CreateObject("NIBLACK.ASPFTP")
- 'specify the server, user name, and password
- objFTP.sServerName = Request.Form("Server")
- objFTP.sUserID = Request.Form("User_ID")
- objFTP.sPassword = Request.Form("Password")
- 'connect to the server
- If objFTP.bConnect Then
- 'connection worked...now delete the file
- If objFTP.bDeleteFile(Request.Form("File")) Then
- 'delete was successful
- strMsg = "Delete Successful!"
- Else
- 'delete failed...let user know
- strMsg = "Delete Failed: " & objFTP.sError
- End If
- Else
- 'connect failed...let user know
- strMsg = objFTP.sError
- End If
- 'clean up...
- Set objFTP = Nothing
- Else
- 'default return msg
- strMsg = ""
- End If
- %>
- <html>
- <body>
- This example uses the standard Delete File method (bDeleteFile). All parameters
- required for deleting 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_DeleteFile_form.asp" method="post" id="form1" name="form1">
- <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>File Name:</td>
- <td><input name="File" size="25"></td>
- </tr><tr>
- <td colspan="2" align="center"><input type="submit" name="DelIt" value="Delete File"></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
AspFTP2_DeleteFile.asp
复制代码
- <%@ LANGUAGE=VBScript %>
- <!--#Include File="aspftp2.inc"-->
- <%
- 'check to see if user submitted form
- If Request.Form("DelIt") <> "" Then
- Dim objFTP
- Dim strMsg
- 'create reference to object
- Set objFTP = Server.CreateObject("NIBLACK.ASPFTP")
- 'specify the server, user name, and password
- objFTP.sServerName = "kii-201094"
- objFTP.sUserID = "anonymous"
- objFTP.sPassword = "wally@wallyworld.com"
- 'connect to the server
- If objFTP.bConnect Then
- 'connection worked...now delete the file
- If objFTP.bDeleteFile("dirmap.txt") Then
- 'delete was successful
- strMsg = "Delete Successful!"
- Else
- 'delete failed...let user know
- strMsg = "Delete Failed: " & objFTP.sError
- End If
- Else
- 'connect failed...let user know
- strMsg = objFTP.sError
- End If
- 'clean up...
- Set objFTP = Nothing
- Else
- 'default return msg
- strMsg = ""
- End If
- %>
- <html>
- <body>
- This example uses the standard Delete File method (bDeleteFile). All parameters
- required for deleting 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_DeleteFile.asp" method="post" id="form1" name="form1">
- <input type="submit" name="DelIt" value="Delete File">
- </form>
- </body>
- </html>
Get文件的例子 Xinsoft,2003-11-02 14:45:55
AspFTP2_Get_form.asp
复制代码
- <%@ 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")
- 'set the properties for the connection
- objFTP.sServerName = Request.Form("Server")
- objFTP.sUserID = Request.Form("User_ID")
- objFTP.sPassword = Request.Form("Password")
- 'connect to the host
- If objFTP.bConnect Then
- 'set the properties for the get function
- objFTP.bOverWrite = Request.Form("OverWrite")
- objFTP.lTransferType = Request.Form("Transfer_Type")
- 'now get the file
- If objFTP.bGetFile(Request.Form("Remote_File"), Request.Form("Local_File")) Then
- 'get was successful
- strMsg = "Get Successful!"
- Else
- 'get failed...let user know
- strMsg = "Get Failed: " & objFTP.sError
- End If
- Else
- 'connection failed...let user know
- strMsg = "Connection Failed: " & objFTP.sError
- End If
- 'clean up...
- Set objFTP = Nothing
- Else
- 'default return msg
- strMsg = ""
- End If
- %>
- <html>
- <body>
- This example uses the Get method (bGetFile). 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_Get_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>
AspFTP2_Get.asp
复制代码
- <%@ 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")
- 'set the properties for the connection
- objFTP.sServerName = "ftp.microsoft.com"
- objFTP.sUserID = "anonymous"
- objFTP.sPassword = "wally@wallyworld.com"
- 'connect to the host
- If objFTP.bConnect Then
- 'set the properties for the get function
- objFTP.bOverWrite = True
- objFTP.lTransferType = TRANSFER_TYPE_ASCII
- 'now get the file
- If objFTP.bGetFile("dirmap.txt", "c:/dirmap.txt") Then
- 'get was successful
- strMsg = "Get Successful!"
- Else
- 'get failed...let user know
- strMsg = "Get Failed: " & objFTP.sError
- End If
- Else
- 'connection failed...let user know
- strMsg = "Connection Failed: " & objFTP.sError
- End If
- 'clean up...
- Set objFTP = Nothing
- Else
- 'default return msg
- strMsg = ""
- End If
- %>
- <html>
- <body>
- This example uses the Get method (bGetFile). 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_Get.asp" method="post">
- <input type="submit" name="GetIt" value="Get File">
- </form>
- </body>
- </html>
Put文件的例子 Xinsoft,2003-11-02 14:49:40
AspFTP2_Put_form.asp
复制代码
- <%@ LANGUAGE=VBScript %>
- <!--#Include File="aspftp2.inc"-->
- <%
- 'check to see if user submitted form
- If Request.Form("PutIt") <> "" Then
- Dim objFTP
- Dim strMsg
- 'create reference to object
- Set objFTP = Server.CreateObject("NIBLACK.ASPFTP")
- 'set the properties for the connection
- objFTP.sServerName = Request.Form("Server")
- objFTP.sUserID = Request.Form("User_ID")
- objFTP.sPassword = Request.Form("Password")
- 'connect to the host
- If objFTP.bConnect Then
- 'set the properties for the put function
- objFTP.lTransferType = Request.Form("Transfer_Type")
- 'now put the file
- If objFTP.bPutFile(Request.Form("Local_File"),Request.Form("Remote_File")) Then
- 'put was successful
- strMsg = "Put Successful!"
- Else
- 'put failed...let user know
- strMsg = "Put Failed: " & objFTP.sError
- End If
- End If
- 'clean up...
- Set objFTP = Nothing
- Else
- 'default return msg
- strMsg = ""
- End If
- %>
- <html>
- <body>
- This example uses the Put method (bPutFile). 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_QPut_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>Local File Name:</td>
- <td><input name="Local_File" size="25"></td>
- </tr><tr>
- <td>Remote File Name:</td>
- <td><input name="Remote_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 colspan="2" align="center"><input type="submit" name="PutIt" value="Put File"></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
AspFTP2_Put.asp
复制代码
- <%@ LANGUAGE=VBScript %>
- <!--#Include File="aspftp2.inc"-->
- <%
- 'check to see if user submitted form
- If Request.Form("PutIt") <> "" Then
- Dim objFTP
- Dim strMsg
- 'create reference to object
- Set objFTP = Server.CreateObject("NIBLACK.ASPFTP")
- 'set the properties for the connection
- objFTP.sServerName = "ftp.microsoft.com"
- objFTP.sUserID = "anonymous"
- objFTP.sPassword = "wally@wallyworld.com"
- 'connect to the host
- If objFTP.bConnect Then
- 'set the properties for the put function
- objFTP.lTransferType = TRANSFER_TYPE_ASCII
- 'now put the file
- If objFTP.bPutFile("c:/test.txt", "test.txt") Then
- 'put was successful
- strMsg = "Put Successful!"
- Else
- 'put failed...let user know
- strMsg = "Put Failed: " & objFTP.sError
- End If
- Else
- 'connection failed...let user know
- strMsg = "Connection Failed: " & objFTP.sError
- End If
- 'clean up...
- Set objFTP = Nothing
- Else
- 'default return msg
- strMsg = ""
- End If
- %>
- <html>
- <body>
- This example uses the Put method (bPutFile). 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_Put.asp" method="post">
- <input type="submit" name="PutIt" value="Put File">
- </form>
- </body>
- </html>
删除目录的例子 Xinsoft,2003-11-02 15:03:10
AspFTP2_RemoveDir_form.asp
复制代码
- <%@ LANGUAGE=VBScript %>
- <!--#Include File="aspftp2.inc"-->
- <%
- 'check to see if user submitted form
- If Request.Form("RemoveIt") <> "" Then
- Dim objFTP
- Dim strMsg
- 'create reference to object
- Set objFTP = Server.CreateObject("NIBLACK.ASPFTP")
- 'specify the server, user name, and password
- objFTP.sServerName = Request.Form("Server")
- objFTP.sUserID = Request.Form("User_ID")
- objFTP.sPassword = Request.Form("Password")
- 'connect to the server
- If objFTP.bConnect Then
- 'connection worked...now remove the directory
- If objFTP.bRemoveDir(Request.Form("Dir")) Then
- 'remove was successful
- strMsg = "Remove Successful!"
- Else
- 'remove failed...let user know
- strMsg = "Removed Failed: " & objFTP.sError
- End If
- Else
- 'connect failed...let user know
- strMsg = objFTP.sError
- End If
- 'clean up...
- Set objFTP = Nothing
- Else
- 'default return msg
- strMsg = ""
- End If
- %>
- <html>
- <body>
- This example uses the standard Remove Directory method (bRemoveDir). All parameters
- required for removing a directory 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_RemoveDir_form.asp" method="post" id="form1" name="form1">
- <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>Directory:</td>
- <td><input name="Dir" size="25"></td>
- </tr><tr>
- <td colspan="2" align="center"><input type="submit" name="RemoveIt" value="Remove Directory"></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
AspFTP2_RemoveDir.asp
复制代码
- <%@ LANGUAGE=VBScript %>
- <!--#Include File="aspftp2.inc"-->
- <%
- 'check to see if user submitted form
- If Request.Form("RemoveIt") <> "" Then
- Dim objFTP
- Dim strMsg
- 'create reference to object
- Set objFTP = Server.CreateObject("NIBLACK.ASPFTP")
- 'specify the server, user name, and password
- objFTP.sServerName = "kii-201094"
- objFTP.sUserID = "anonymous"
- objFTP.sPassword = "wally@wallyworld.com"
- 'connect to the server
- If objFTP.bConnect Then
- 'connection worked...now remove the directory
- If objFTP.bRemoveDir("test") Then
- 'remove was successful
- strMsg = "Remove Successful!"
- Else
- 'remove failed...let user know
- strMsg = "Remove Failed: " & objFTP.sError
- End If
- Else
- 'connect failed...let user know
- strMsg = objFTP.sError
- End If
- 'clean up...
- Set objFTP = Nothing
- Else
- 'default return msg
- strMsg = ""
- End If
- %>
- <html>
- <body>
- This example uses the standard Remove Directory method (bRemoveDir). All parameters
- required for removing a directory are explicitly defined in the ASP code.<br>
- <hr>
- <br>
- <%If strMsg <> "" Then%>
- Return Message: <%=strMsg%><br>
- <hr>
- <br>
- <%End If%>
- <form action="AspFTP2_RemoveDir.asp" method="post" id="form1" name="form1">
- <input type="submit" name="RemoveIt" value="Remove Directory">
- </form>
- </body>
- </html>