Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3180 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Sometimes you need to upload a file to FTP/FTPS/SFTP server, e.g. upload a backup. The following script does that and can run even on a FileMaker server:

Set Variable [$curl; Value:MBS("CURL.New")]

# Path to the input file with data to upload

Set Variable [$result; Value:MBS("CURL.OpenInputFile"; $curl; "/Users/cs/Desktop/test.jpg")]

# Set upload options

Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "ftp://monkeybreadsoftware.de/test/test.jpg")]

Set Variable [$result; Value:MBS("CURL.SetOptionUpload"; $curl; 1)]

Set Variable [$result; Value:MBS("CURL.SetOptionPassword"; $curl; "secret")]

Set Variable [$result; Value:MBS("CURL.SetOptionUsername"; $curl; "account")]

# Run Transfer

Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]

# get log

Set Field [CURL Test::DebugMessages; MBS("CURL.GetDebugAsText"; $curl)]

# and clean up

Set Variable [$result; Value:MBS("CURL.Cleanup"; $curl)]

As you see we pass in an URL for the ftp upload. Depending on whether we use ftp:// (unsecure), ftps:// (ftp with SSL) or sftp:// (ssh), we get the protocol for the URL. If you need to upload a container, you can use CURL.SetInputFile or for text the function CURL.SetInputText. Don't forget to include in the URL the new file name on the target. 

Other interesting options here are CURL.SetOptionFTPCreateMissingDirs for creating missing directories, CURL.SetOptionConnectionTimeout for setting connection timeout and CURL.SetOptionPort if your server doesn't use the standard port for the protocol.

I hope this helps you guys.

This topic is 3180 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.