CURL.SetOptionFTPCreateMissingDirs
----------------------------------

Whether to create missing directories.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [2.5](newinversion25.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.SetOptionFTPCreateMissingDirs"; curl; Value ) 

**MBS**( **"CURL.SetOptionFTPCreateMissingDirs";** /\* Whether to create missing directories. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Value**) /\* Whether to create missing directories. (1, 2 or 0)e.g. 2 \*/ 

### 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](https://curl.haxx.se/libcurl/c/CURLOPT_FTP_CREATE_MISSING_DIRS.html) option in CURL manual.

### Examples

Upload via FTP with creation of missing folders:

 Set Variable \[ $curl ; Value: MBS ("[CURL.New](CURLNew.md)") \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $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](CURLSetOptionPassword.md)"; $curl ; CURL Test::Password ) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)"; $curl ; CURL Test::Name ) \]   
\# we upload some text here.   
Set Variable \[ $result ; Value: MBS ("[CURL.SetInputText](CURLSetInputText.md)"; $curl ; "Hello World!") \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionUpload](CURLSetOptionUpload.md)"; $curl ; 1) \]   
\# Run transfer   
Set Field \[ CURL Test::Result ; MBS ("[CURL.Perform](CURLPerform.md)"; $curl ) \]   
\# Check debug messages for errors   
Set Field \[ CURL Test::debug ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl ) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.Release](CURLRelease.md)"; $curl ) \]  
Upload via SFTP and create missing diretories:

 Set Variable \[ $curl ; Value: MBS ("[CURL.New](CURLNew.md)") \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $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](CURLSetOptionPassword.md)"; $curl ; CURL Test::Password ) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)"; $curl ; CURL Test::Name ) \]   
Set Variable \[ $result ; Value: MBS ( "[CURL.SetOptionSSHAuthTypes](CURLSetOptionSSHAuthTypes.md)"; $curl ; 2+8 ) \]   
\# we upload some text here.   
Set Variable \[ $result ; Value: MBS ("[CURL.SetInputText](CURLSetInputText.md)"; $curl ; "Hello World!") \]   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionUpload](CURLSetOptionUpload.md)"; $curl ; 1) \]   
\# Run transfer   
Set Field \[ CURL Test::Result ; MBS ("[CURL.Perform](CURLPerform.md)"; $curl ) \]   
\# Check debug messages for errors   
Set Field \[ CURL Test::debug ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl ) \]   
Set Variable \[ $result ; Value: MBS ("[CURL.Release](CURLRelease.md)"; $curl ) \]  
### See also

- [CURL.GetDebugMessages](CURLGetDebugMessages.md)
- [CURL.New](CURLNew.md)
- [CURL.Perform](CURLPerform.md)
- [CURL.Release](CURLRelease.md)
- [CURL.SetInputText](CURLSetInputText.md)
- [CURL.SetOptionPassword](CURLSetOptionPassword.md)
- [CURL.SetOptionSSHAuthTypes](CURLSetOptionSSHAuthTypes.md)
- [CURL.SetOptionUpload](CURLSetOptionUpload.md)
- [CURL.SetOptionURL](CURLSetOptionURL.md)
- [CURL.SetOptionUserName](CURLSetOptionUserName.md)

### Example Databases

- [CURL/SFTP/CURL sFTP Upload File](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/SFTP/CURL%20sFTP%20Upload%20File.shtml#1ScriptAnchor_)

### Blog Entries

- [Translating Insert from URL options for CURL to MBS Plugin calls](https://www.mbsplugins.de/archive/2020-12-14/Translating_Insert_from_URL_op/monkeybreadsoftware_blog_filemaker)

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

  
[CURL.SetOptionFTPAlternativeToUser](CURLSetOptionFTPAlternativeToUser.md) - [CURL.SetOptionFTPFileMethod](CURLSetOptionFTPFileMethod.md)

[HTML Version](CURLSetOptionFTPCreateMissingDirs.shtml)