Description

This function returns an account's home directory's path in URI-encoded format.

Examples 




https://hostname.example.com:2087/cpsess##########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Fileman&cpanel_jsonapi_func=getdir&dir=public_html



$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Returns an account's home directory file path. 
$getdir = $cpanel->api2(
    'Fileman', 'getdir'
);

 



my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Returns an account's home directory file path.
my $getdir = $cpliveapi->api2(
    'Fileman', 'getdir',
 );

 




cpapi2 --user=username Fileman getdir



{
  "cpanelresult": {
    "apiversion": 2,
    "func": "getdir",
    "data": [
      {
        "dir": "%2fhome%2fexample%2fpublic_html"
      }
    ],
    "event": {
      "result": 1
    },
    "module": "Fileman"
  }
}



Parameters

ParameterTypeDescriptionPossible valuesExample

dir

string

The directory for which to retrieve the file path.

Regardless of whether you use this parameter, the function will return the dir value.


A valid directory on the server.public_html

Returns

ReturnTypeDescriptionPossible valuesExample
dirstring

The absolute path to the account's home directory.

A valid path, in URI-encoded format.
%2fhome%2fexample%2fpublic_html
 
reasonstring

A reason for failure.

This function only returns a reason value if an error occurred.


A string that describes the error. This is an error message.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1