CURLOPT\_NEW\_DIRECTORY\_PERMS(3) Library Functions Manual CURLOPT\_NEW\_DIRECTORY\_PERMS(3)

# [NAME](#NAME)

CURLOPT\_NEW\_DIRECTORY\_PERMS - permissions for remotely created directories

# [SYNOPSIS](#SYNOPSIS)

```
#include <curl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NEW_DIRECTORY_PERMS,


                          long mode);
```

# [DESCRIPTION](#DESCRIPTION)

Pass a long as a parameter, containing the value of the permissions that is set on newly created directories on the remote server. The default value is *0755*, but any valid value can be used. The only protocols that can use this are *sftp://*, *scp://*, and *file://*.

# [DEFAULT](#DEFAULT)

0755

# [PROTOCOLS](#PROTOCOLS)

This functionality affects file, scp and sftp

# [EXAMPLE](#EXAMPLE)

```
int main(void)
{


  CURL *curl = curl_easy_init();


  if(curl) {


    CURLcode result;


    curl_easy_setopt(curl, CURLOPT_URL,


                     "sftp://upload.example.com/newdir/file.zip");


    curl_easy_setopt(curl, CURLOPT_FTP_CREATE_MISSING_DIRS, 1L);


    curl_easy_setopt(curl, CURLOPT_NEW_DIRECTORY_PERMS, 0644L);


    result = curl_easy_perform(curl);


  }
}
```

# [AVAILABILITY](#AVAILABILITY)

Added in curl 7.16.4

# [RETURN VALUE](#RETURN_VALUE)

[*curl\_easy\_setopt(3)*](/man/os/curl/curl_easy_setopt.3) returns a CURLcode indicating success or error.

CURLE\_OK (0) means everything was OK, non-zero means an error occurred, see [*libcurl-errors(3)*](/man/os/curl/libcurl-errors.3).

# [SEE ALSO](#SEE_ALSO)

[**CURLOPT\_FTP\_CREATE\_MISSING\_DIRS**(3)](/man/os/curl/CURLOPT_FTP_CREATE_MISSING_DIRS.3), [**CURLOPT\_NEW\_FILE\_PERMS**(3)](/man/os/curl/CURLOPT_NEW_FILE_PERMS.3), [**CURLOPT\_UPLOAD**(3)](/man/os/curl/CURLOPT_UPLOAD.3)

2026-09-24 libcurl

---

Document: CURLOPT_NEW_DIRECTORY_PERMS(3) from curl 8.22.0-r3 (Chainguard OS)
Source: https://github.com/curl/curl.git
