UAPI Functions - Fileman::autocompletedir

Description

This function returns any files and directories that begin with a specified string.

Examples


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/execute/Fileman/autocompletedir?path=public&dirs_only=1&list_all=0

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// Search for directories that begin with public.
$search_directories $cpanel->uapi(
    'Fileman''get_file_content',
        array(
        'path'          => 'public',
        'dirsonly'      => '1',
        'list_all'      => '0',
 )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# Search for directories that begin with public.
my $ search_directories = $cpliveapi->uapi(
    'Fileman''autocompletedir',
        {
        'path'          => 'public',
        'dirsonly'      => '1',
        'list_all'      => '0',
        }
 );

 cPanel Template Toolkit

<!-- Get a hash of all the data, then display the path value. -->
[% data = execute( 'Fileman', 'autocompletedir' {'path' => 'public, 'dirs_only' => '1', 'list_all' => '0',} ); %]
[% FOREACH q = data.path %]
     <p>
         [% q %]
     </p>
[% END %]
  
<!-- Get only a hash of the data. -->
[% execute( 'Fileman', 'autocompletedir' {'path' => 'public, dirs_only => '1', 'list_all' => '0',}  ).data.path %]

 Command Line

uapi --user=username Fileman autocompletedir path=public dirs_only=1 list_all=0

 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.

 Output (JSON)

   "data":[ 
      
         "file":"public_html"
      },
      
         "file":"public_ftp"
      },
      
         "file":"public.html"
      }
   ],
   "messages":null,
   "metadata":{ 
      "transformed":1
   },
   "status":1,
   "errors":null
}

 

Note:

Use cPanel's API Shell interface (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

 Parameters 

 Type 

Description

Possible values

 Example 

path

 string 

Required

The prefix of the paths to complete.

A valid string.

public

dirsonly

string

Whether to include only directories in the output.

This value defaults to 0.

  • 1 — Only include directories.
  • 0 — Include directories and files.

1

list_all

string

Whether to return all files and directories inside the specified directory.

 If you set this parameter's value to 1, you must set thepath parameter's value to a full directory path. 

This value defaults to 0.

  • 1 — Return all files and directories inside the specified directory. 
  • 0 — Return partial file and directory name matches.

0

 

Returns

Return

Type

Description

Possible values

Example

 

 array of hashes 

 An array of hashes that contains the files and directories that match the specified path. 

 This array of hashes includes the file return. 

 

file

string

A file or directory that matches the specified path.

The function returns this value in the unnamed array of hashes.

A valid filename or directory name.

 public_ftp 

 

  • 6 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....