I'm not familiar with the BlockingUpload method that you're using for the
Chilkat FTP object.
Here is code that I wrote to do FTP uploading of a file using the Chilkat
object. The FTP_Copy function is called from another VBA procedure, and that
procedure passes along the first three arguments to the function. The
FTP_Copy function will create a directory/folder if the desired folder is
not present; for the application that I used this function in, there was a
master folder and a subfolder under that master folder. The file was put
into the subfolder. This function creates the master folder if it's not
there, and also creates the subfolder if it's not there.
Private Function FTP_Copy(strParentFTPFolder As String, _
strFTPServerFolderToUse As String, _
strFilePathBeingCopied As String, _
Optional ByVal strFileNameToUseOnFTP As String = "") As Boolean
Dim strFile As String, strFileFTP As String
Dim strFilePath As String
Dim intSuccess As Integer
Dim ftpObj As ChilkatFTP
On Error Resume Next
strFile = ExtractFileName(strFilePathBeingCopied)
strFilePath = ExtractPath(strFilePathBeingCopied)
If strFileNameToUseOnFTP = "" Then strFileNameToUseOnFTP = strFile
Set ftpObj = New ChilkatFTP
With ftpObj
' replace generic strings with real values in the following three lines
.Hostname = "NameOfTheFTPServer" ' server IP or FTP address
.UserName = "UserName"
.Password = "Password"
.Passive = 1
intSuccess = .Connect
If intSuccess = 0 Then
FTP_Copy = False
Else
intSuccess = .CreateRemoteDir(strParentFTPFolder)
intSuccess = .ChangeRemoteDir(strParentFTPFolder)
If intSuccess = 0 Then
FTP_Copy = False
Else
intSuccess = .CreateRemoteDir(strFTPServerFolderToUse)
intSuccess = .ChangeRemoteDir(strFTPServerFolderToUse)
If intSuccess = 0 Then
FTP_Copy = False
Else
intSuccess = .PutFile(strFilePath & strFile,
strFileNameToUseOnFTP)
If intSuccess = 0 Then
FTP_Copy = False
Else
FTP_Copy = True
End If
End If
End If
.Disconnect
End If
End With
Set ftpObj = Nothing
Err.Clear
Exit Function
End Function
Private Function ExtractFileName(ByVal strPathFile As String) As String
'*** THIS FUNCTION EXTRACTS THE "FILE NAME" PORTION OF A STRING THAT HOLDS
'*** THE FULL PATH AND FILENAME FOR A FILE. IT DOES THIS BY DROPPING
'*** THE PATH PORTION FROM THE STRING (ALL TEXT BEFORE THE LAST
'*** "\" CHARACTER IN THE STRING, AND THAT LAST "\" CHARACTER, TOO).
'*** IF THERE IS NO "\" CHARACTER IN THE TEXT STRING, THE FUNCTION RETURNS
'*** AN EMPTY STRING AS ITS VALUE. OTHERWISE, IT RETURNS THE "FILE NAME"
PORTION
'*** OF THE TEXT STRING.
' strPathFile is string variable that contains the full path and filename
text string.
On Error Resume Next
If InStr(strPathFile, "\") = 0 Then
ExtractFileName = ""
Else
ExtractFileName = Mid(strPathFile, InStrRev(strPathFile, "\") + 1)
End If
Err.Clear
Exit Function
End Function
Private Function ExtractPath(ByVal strPathFile As String) As String
'*** THIS FUNCTION EXTRACTS THE "PATH" PORTION OF A STRING THAT HOLDS
'*** THE FULL PATH AND FILENAME FOR A FILE. IT DOES THIS BY DROPPING
'*** THE FILENAME PORTION FROM THE STRING (ALL TEXT AFTER THE LAST
'*** "\" CHARACTER IN THE STRING).
'*** IF THERE IS NO "\" CHARACTER IN THE TEXT STRING, THE FUNCTION RETURNS
'*** AN EMPTY STRING AS ITS VALUE. OTHERWISE, IT RETURNS THE "PATH" PORTION
'*** (INCLUDING THE ENDING "\" CHARACTER) OF THE TEXT STRING.
' strPathFile is string variable that contains the full path and filename
text string.
On Error Resume Next
If InStr(strPathFile, "\") = 0 Then
ExtractPath = ""
Else
ExtractPath = Left(strPathFile, InStrRev(strPathFile, "\"))
End If
Err.Clear
Exit Function
End Function