cPanel API 2 Functions - Fileman::statfiles

Description

This function lists file information.

Warning:

This function is deprecated as of cPanel version 11.40+. 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.

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

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

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

 cPanel Tag System (deprecated)

Warning:

In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We strongly recommend that youonly use the LiveAPI system to call the cPanel APIs.

cPanel API 2 calls that use cPanel tags vary widely in code syntax and in their output. For more information, read our Deprecated cPanel Tag Usage documentation. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI.

 

 Command Line

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

 

Notes:

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

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

Note:

Use cPanel's API Shell interface (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.

 Note:

 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 notinclude 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 /homedirectory.

 home/user/public_html 

 type

 string

 The item type.

  • file
  • dir
  • char
  • block
  • fifo
  • link
  • socket

 file

 gid

 integer

 The file owner's system group ID.

 A valid group ID number.

 508

 reason

 string

 A reason for failure.

 Note:

 This function only returns a reasonvalue if an error occurred. 

 A string that describes the error.

 This is an error message.

 result

 Boolean 

 Whether the function succeeded.

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

 1

    

  • 0 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....