Page tree
Skip to end of metadata
Go to start of metadata

 

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

Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 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',
 )
);

Note:

For more information, read our Guide to the LiveAPI System.

 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',
		}
 );

Note:

For more information, read our Guide to the LiveAPI System.

 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 %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 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.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 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 (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

ParametersTypeDescriptionPossible valuesExample
pathstring

Required

The prefix of the paths to complete.

A valid string.public
dirsonlystring

Whether to include only directories in the output.

This value defaults to 0.

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

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

If you set this parameter's value to 1, you must set the path 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

ReturnTypeDescriptionPossible valuesExample
 array of hashesAn 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