View Full Version : Using csFTPquick to FTP via ASP

April 13th, 2010, 02:13 PM
Here is a code sample to use the csFTPquick component to FTP via FTP. We do not have this installed on every server, so if you get an error about not being able to createobject, submit a support ticket (http://support.hostek.com) and we can get this installed.


Dim strHost, strUser, strPass, LocalDir, RemoteDir, strFiles

strHost = "ftp.your__destination_domain.com"
strUser = "username"
strPass = "password"
strRemoteDir = "images"
strLocalDir = Request.ServerVariables("APPL_PHYSICAL_PATH") & "images\"
strFiles = "myimage.jpg"

Set objFTP = Server.CreateObject("csFTPQuick.FTPCommands")

'--NOTE: This ActiveMode option is a new feature ChestySoft.com added to allow Passive FTP
'-- False = Passive
objFTP.ActiveMode = False

objFTP.Connect strHost, strUser, strPass
objFTP.SetCurrentDirectory strRemoteDir

'--uncomment these lines to see a list of files on the FTP site
'For i = 0 to objFTP.FileListCount - 1
' Response.Write objFTP.FileList(i) & "<br />"

objFTP.UploadFile strLocalDir & strFiles
On Error Resume Next
if err <> 0 then
response.write "UploadFile error - " & err.description & "<br />"
response.write "UploadFile OK<br />"
end if

response.write "FTP DISCONNECTED"