<html>
<head><title>IASPInet Test</title><head>
<body bgcolor=white text=black>
<H2>InetASP Test</H2>
</font>
<%if(request.form("HostName") = "" and request.form("UserName") = "") then%>
<p align="left"><font color="#000000" size="5">
<em>Please enter parameters:</em></font></p>
<form action="iaspinet.asp" method="post">
<p align="left">
<strong>HostName :</strong></font>
<input type="text" size="24" value="" name="HostName">
</p>
<p align="left">
<strong>UserName :</strong>
<input type="text" size="28" name="UserName">
</p>
<p align="left">
<strong>Password :</strong>
<INPUT name="password" type=password style="WIDTH: 100px; HEIGHT: 22px">
</p>
<p align="left">
<strong>RemoteFile:</strong>
<input type="text" size="28" name="RemoteFile">
</p>
<p align="left">
<strong>LocalFile :</strong>
<input type="text" size="28" name="LocalFile">
</p>
<p><input type="checkbox" name="Check1" value="On"> Overwrite the exist file?</p>
<p align="left">
<strong>Mode:</strong>
<input type="text" size="6" name="Mode" value="1">
</p>
<input type="submit" size="6" name="submit1" value="Put File">
<input type="submit" size="6" name="submit1" value="Get File">
</form>
<%
else
rem *************************************************************************
rem *
rem * This is certainly not the way I would implement an "industrial strength"
rem * FTP system. I would probably create a job queue that offloads the
rem * processing onto another system besides IIS with IIS simply serving as
rem * the gateway to the interface but that is "for another day".
rem *
rem * Session timeout's become an issue for files that take longer to transfer than
rem * the session timeout will allow. I suspect that the file transfer will continue
rem * even after the session times out but I have not tested this.
rem *
rem * IASPInet.FTP has two methods:
rem * FTPGetFile(strHostName, strUserName, strPassword,
rem * strRemoteFileName, strLocalFileName, bolOverwrite)
rem * FTPPutFile(strHostName, strUserName, strPassword,
rem * strRemoteFileName, strLocalFileName)
rem *
rem * The return value is a boolean indicating success or failure.
rem *
rem *************************************************************************
FTP_TRANSFER_TYPE_ASCII = 1
FTP_TRANSFER_TYPE_BINARY = 2
'Dim FtpConn,HostName,UserName,Password,RemoteFile,LocalFile,BoolOverwrite
Set FtpConn = Server.CreateObject("AspInet.FTP")
rem *************************************************************************
rem *
rem * GET File Test
rem *
rem *************************************************************************
HostName = request.form("HostName")
UserName = request.form("UserName")
Password = request.form("Password")
RemoteFile = request.form("RemoteFile")
LocalFile = request.form("LocalFile")
mode = request.form("mode")
BoolOverwrite = false
if (request.form("Check1") = "On") then
BoolOverwrite = true
end if
if (request.form("submit1") = "Get File") then
if FtpConn.FTPGetFile(HostName, UserName, Password, RemoteFile, LocalFile, BoolOverwrite, mode) then
Response.Write "<p>FTP download Success...<br>"
else
Response.Write "<p>FTP download Faileed...<br>"
Response.Write "Last Error was: " & FtpConn.LastError
end if
end if
rem *************************************************************************
rem *
rem * PUT File Test
rem *
rem *************************************************************************
if (request.form("submit1") = "Put File") then
if FtpConn.FTPPutFile(HostName, UserName, Password, RemoteFile, LocalFile, mode) then
Response.Write "<p>FTP upload Success...<br>"
else
Response.Write "<p>FTP upload Failed...<br>"
Response.Write "Last Error was: " & FtpConn.LastError
end if
end if
end if
%>
</body>
</html>
|