MBS CURL Plugin FTP changing filename

I’m using the “CURLS ftp file upload direct” example, and while it uploads the file to the ftp server, the name of the file gets changed from “something.zip” to
OptionUsername.

If I change the name back on the ftp, and add .zip extension, the file works.

I’ve tried other ftp Curl examples, and they all do the same thing - the file gets uploaded, but with the user name as the file name

dim d as new UploadCURL

if d.OpenMTInputFile(f) then
  // ok
else
  MsgBox "Failed to open file."
  Return
End If

d.OptionURL = url.Text
d.OptionUpload = True
d.OptionVerbose = true // generate messages
d.CollectDebugMessages = true // collect them

d.OptionUsername = "the_user_name"
d.OptionPassword = "00000-00000-00000"
d.OptionSSHAuthTypes = 2+8 // for SFTP: only allow keyboard or interactive login, no public key


dim e as integer = d.Perform

dim DebugMessages as string = d.DebugMessages
// check those in debugger in case of errors

listbox1.addrow "Result: "+str(e)

if e <> 0 then
  break
end if

The file name on the server goes into the URL.
Don’t forget to use EncodeURLComponent() for this.

e.g.

d.OptionURL = "ftp://test.server.com/folder/" + EncodeURLComponent(filename)

d.CollectDebugMessages and d.OptionVerbose are now on by default, so the lines are no longer needed.

With filename “TestFile.zip” and username “Doug_Adams” and ftp “ftp://myserver.com/Doug_Adams”, I’m getting a file name of “Doug_AdamsTestFile.zip”

if I use “ftp://myserver.com/Doug_Adams/” I get an error result 9.

Error 9 may be ‘Server denied you to change to the given directory’
Do you have Doug_Adams folder?
Do you have the rights to read/write to it?

Note: if you are connecting as the user maybe the path is relative to the user’s default dir.

Leave the Doug_Adams part away.
You are probably already in that folder.

2 Likes

That’s a Bingo! Thanks Christian!