Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CURL.SetOptionFTPCreateMissingDirs

Whether to create missing directories.

Component Version macOS Windows Linux Server iOS SDK
CURL 2.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "CURL.SetOptionFTPCreateMissingDirs"; curl; Value )   More

Parameters

Parameter Description Example
curl The CURL session handle. $curl
Value Whether to create missing directories. (1, 2 or 0) 2

Result

Returns "OK" on success.

Description

Whether to create missing directories.
Pass a number. If the value is 1, curl will attempt to create any remote directory that it fails to CWD into. CWD is the command that changes working directory.

This setting also applies to SFTP-connections. curl will attempt to create the remote directory if it can't obtain a handle to the target-location. The creation will fail if a file of the same name as the directory to create already exists or lack of permissions prevents creation.

Starting with 7.19.4, you can also set this value to 2, which will make libcurl retry the CWD command again if the subsequent MKD command fails. This is especially useful if you're doing many simultanoes connections against the same server and they all have this option enabled, as then CWD may first fail but then another connection does MKD before this connection and thus MKD fails but trying CWD works!

See also FTP_CREATE_MISSING_DIRS option in CURL manual.

Examples

Upload via FTP with creation of missing folders:

Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; "ftp://ftp.monkeybreadsoftware.net/missingFolder/hello.txt") ]
# create any missing folders when uploading
Set Variable [ $result ; Value: MBS("CURL.SetOptionFTPCreateMissingDirs"; $curl; 1) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; CURL Test::Password) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUserName"; $curl; CURL Test::Name) ]
# we upload some text here.
Set Variable [ $result ; Value: MBS("CURL.SetInputText"; $curl; "Hello World!") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUpload"; $curl; 1) ]
# Run transfer
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
# Check debug messages for errors
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]

Upload via SFTP and create missing diretories:

Set Variable [ $curl ; Value: MBS("CURL.New") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; "sftp://ftp.monkeybreadsoftware.net/missingFolder/hello.txt") ]
# create any missing folders when uploading
Set Variable [ $result ; Value: MBS("CURL.SetOptionFTPCreateMissingDirs"; $curl; 1) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionPassword"; $curl; CURL Test::Password) ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUserName"; $curl; CURL Test::Name) ]
Set Variable [ $result ; Value: MBS( "CURL.SetOptionSSHAuthTypes"; $curl; 2+8 ) ]
# we upload some text here.
Set Variable [ $result ; Value: MBS("CURL.SetInputText"; $curl; "Hello World!") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionUpload"; $curl; 1) ]
# Run transfer
Set Field [ CURL Test::Result ; MBS("CURL.Perform"; $curl) ]
# Check debug messages for errors
Set Field [ CURL Test::debug ; MBS("CURL.GetDebugMessages"; $curl) ]
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]

See also

Example Databases

Blog Entries

Created 18th August 2014, last changed 19th April 2020


CURL.SetOptionFTPAlternativeToUser - CURL.SetOptionFTPFileMethod