cPanel API 2 Functions - Fileman::statfiles
The cPanel API 2 system is deprecated. We strongly recommend that you use UAPI instead of cPanel API 2.
Description
This function lists file information.
We strongly recommend that you use the UAPI function instead of this function:
-
Fileman::get_file_information
— This function returns the information for a specified file or directory.
When you disable the File Storage role, the system disables this function.
Examples
WHM API (JSON)
https://hostname.example.com:2087/cpsess##########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Fileman&cpanel_jsonapi_func=statfiles&dir=public_html&files=file.html%7Cfile2.html%7Cfile3.php
For more information, read our Calls from the WHM API documentation.
LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
// List information about specific files in /home/user/public_html.
$stat_files = $cpanel->api2(
'Fileman', 'statfiles',
array(
'dir' => 'public_html'
'files' => 'file.html|file2.html|file3.php'
)
);
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.
# List information about specific files in /home/user/public_html.
my $stat_files = $cpanel->api2(
'Fileman', 'statfiles',
{
'dir' => 'public_html'
'files' => 'file.html|file2.html|file3.php'
);
For more information, read our Guide to the LiveAPI System.
cPanel Tag System (deprecated)
- cPanel tags are deprecated . We strongly recommend that you only use the LiveAPI system to call the cPanel APIs. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI .
- cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
- For more information, read our Deprecated cPanel Tag Usage documentation.
Command Line
cpapi2 --user=username Fileman statfiles dir=public_html files=file.html%7Cfile2.html%7Cfile3.php
- You must URI-encode values.
-
username
represents your account-level username. -
You
must
include the
--user=username
option. -
For more information and additional output options, read our
Guide to cPanel API 2
documentation or run the
cpapi2 --help
command. -
If you run CloudLinux™, you
must
use the full path of the
cpapi2
command:/usr/local/cpanel/bin/cpapi2
Output (JSON)
{
"cpanelresult": {
"apiversion": 2,
"func": "statfiles",
"data": [
{
"mode": 33188,
"file": "file.html",
"rawmimetype": "text/html",
"nicemode": "0644",
"size": "",
"humansize": "0 bytes",
"group": "example",
"fullpath": "/home/example/public_html/file.html",
"user": "example",
"ctime": 1414609879,
"uid": 517,
"mtime": 1414609879,
"mimename": "text-html",
"path": "/home/example/public_html",
"mimeinfo": "text/html",
"rawmimename": "text-html",
"absdir": "/home/example/public_html",
"type": "file",
"exists": 1,
"gid": 517
},
{
"mode": 33188,
"file": "file2.html",
"rawmimetype": "text/html",
"nicemode": "0644",
"size": "",
"humansize": "0 bytes",
"group": "example",
"fullpath": "/home/example/public_html/file2.html",
"user": "example",
"ctime": 1414609890,
"uid": 517,
"mtime": 1414609890,
"mimename": "text-html",
"path": "/home/example/public_html",
"mimeinfo": "text/html",
"rawmimename": "text-html",
"absdir": "/home/example/public_html",
"type": "file",
"exists": 1,
"gid": 517
},
{
"mode": 33188,
"file": "file3.php",
"rawmimetype": "text/x-generic",
"nicemode": "0644",
"size": "",
"humansize": "0 bytes",
"group": "example",
"fullpath": "/home/example/public_html/file3.php",
"user": "example",
"ctime": 1414609900,
"uid": 517,
"mtime": 1414609900,
"mimename": "text-x-generic",
"path": "/home/example/public_html",
"mimeinfo": "text/x-generic",
"rawmimename": "text-x-generic",
"absdir": "/home/example/public_html",
"type": "file",
"exists": 1,
"gid": 517
}
],
"event": {
"result": 1
},
"module": "Fileman"
}
}
Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.
Parameters
Parameter | Type | Description | Possible values | Example |
---|---|---|---|---|
dir |
string | The directory to query. |
Any valid directory name. | public_html |
files |
Boolean | Required The files to query. |
One or more valid file names. Separate multiple files with the pipe character ( |
file.html|file2.html|file3.php |
Returns
Return | Type | Description | Possible values | Example |
---|---|---|---|---|
mode |
string | The file's permissions. | A set of file permissions, in textual representation format. | 33188 |
file |
string | The file's name. | A valid filename. | file.html |
rawmimetype |
string | The file's MIME type. | A valid MIME type. | text/html |
nicemode |
integer | The file's permissions. | A set of file permissions, in octal notation format. | 0777 |
size |
integer | The size of the file. | A positive integer, in bytes. | 4096 |
humansize |
string | The formatted size of the file. | A positive integer, in megabytes (MB ), kilobytes (KB ), or gigabytes (GB ). |
4 KB |
group |
string | The file owner's system group name. | A valid group name. | example |
absolutepath |
string | The absolute path to the file. |
A valid absolute file path. | /home/example/public_html/file.html |
user |
string | The file owner's system username. | A valid system username. | example |
ctime |
integer | The file's creation time. | A Unix time stamp. | 1371711650 |
uid |
integer | The file owner's user ID. | A valid user ID on the server. |
517 |
mtime |
integer | The file's last modification time. | A Unix time stamp. | 1411211655 |
mimename |
string | The file's MIME name. | A valid MIME name. | text-html |
path |
string | The absolute path to the file. |
A valid absolute file path. This value does not include the file or directory name. |
/home/example/public_html |
mimeinfo |
string | The file's MIME type. | Any valid MIME type. | text/html |
rawmimename |
string | The file's MIME name. | Any valid MIME name. | text-html |
absdir |
string | The directory's absolute path. | A valid directory, relative to the account's /home directory. |
home/user/public_html |
type |
string | The item type. |
|
file |
gid |
integer | The file owner's system group ID. | A valid group ID number. | 508 |
reason |
string |
A reason for failure. This function only returns a |
A string that describes the error. | This is an error message. |
result |
Boolean | Whether the function succeeded. |
|
1 |