Description

This function lists file information.


This function is deprecated as of cPanel version 11.40+. We strongly recommend that you use the UAPI function instead of this function:

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=statfiles&dir=public_html&files=file.html%7Cfile2.html%7Cfile3.php



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

 



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




cpapi2 --user=username Fileman statfiles dir=public_html files=file.html%7Cfile2.html%7Cfile3.php



{
  "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"
  }
}



Parameters

ParameterTypeDescriptionPossible valuesExample
dirstring

The directory to query.

Any valid directory name.public_html
filesBoolean

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

ReturnTypeDescriptionPossible valuesExample
modestringThe file's permissions.A set of file permissions, in textual representation format.
33188
filestringThe file's name.A valid filename.file.html
rawmimetypestringThe file's MIME type.A valid MIME type.
text/html
nicemodeintegerThe file's permissions.A set of file permissions, in octal notation format.
0777
sizeintegerThe size of the file.A positive integer, in bytes.4096
humansizestringThe formatted size of the file.A positive integer, in Megabytes (MB), Kilobytes (KB), or Gigabytes (GB).4 KB
groupstringThe file owner's system group name.A valid group name.example
absolutepathstring

The absolute path to the file.

A valid absolute file path.
/home/example/public_html/file.html
userstringThe file owner's system username.A valid system username.example
ctimeintegerThe file's creation time.A Unix time stamp.1371711650
uidintegerThe file owner's user ID.

A valid user ID on the server.

517
mtimeintegerThe file's last modification time.A Unix time stamp .
                1411211655
              
mimenamestringThe file's MIME name.A valid MIME name.
text-html
pathstring

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
mimeinfostringThe file's MIME type.Any valid MIME type.
text/html
rawmimenamestringThe file's MIME name.Any valid MIME name.
text-html
absdirstringThe directory's absolute path.A valid directory, relative to the account's /home directory. home/user/public_html
typestringThe item type.
  • file
  • dir
  • char
  • block
  • fifo
  • link
  • socket
file
gidintegerThe file owner's system group ID.A valid group ID number.508
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