# cPanel API 2 Functions - Fileman::viewfile

Warning:
The cPanel API 2 system is deprecated. We **strongly** recommend that you use [UAPI](/cpanel/introduction) instead of cPanel API 2.

## Description

This function lists file information.

Warning:
We **strongly** recommend that you use the following [UAPI](/cpanel/introduction/) function instead of this function:

- [`Fileman::list_files`](/openapi/cpanel/operation/list_files/) — This function returns a sorted list of files and directories.


Important:
When you disable the [*File Storage* role](https://docs.cpanel.net/knowledge-base/general-systems-administration/how-to-use-server-profiles/#roles), the system **disables** this function.

## Examples

WHM API (JSON)


```undefined syntaxhighlighter-pre
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
```

Note:
For more information, read our [Calls from the WHM API](/whm/use-whm-api-to-call-cpanel-api-and-uapi) documentation.

LiveAPI PHP Class


```undefined syntaxhighlighter-pre
$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'
 )
);
```

Note:
For more information, read our [Guide to the LiveAPI System](/guides/guide-to-the-liveapi-system/#guide-to-the-liveapi-system).

LiveAPI Perl Module


```undefined syntaxhighlighter-pre
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'
 );
```

Note:
For more information, read our [Guide to the LiveAPI System](/guides/guide-to-the-liveapi-system/#guide-to-the-liveapi-system).

cPanel Tag System (deprecated)

Warnings:
- cPanel tags are **deprecated**. We **strongly** recommend that you **only** use the [LiveAPI](/guides/guide-to-the-liveapi-system) 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](/guides/guide-to-the-liveapi-system).
- 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](/cpanel-api-2/cpanel-api-2-deprecate-cpanel-tag-usage/) documentation.


Command Line


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

div
Notes:

- 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](/cpanel-api-2/) documentation or run the `cpapi2 --help` command.
- If you run CloudLinux™, you **must** use the full path of the `cpapi2` command:

```undefined syntaxhighlighter-pre
/usr/local/cpanel/bin/cpapi2
```


br
Output (JSON)


```undefined syntaxhighlighter-pre
{
  "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](https://docs.cpanel.net/cpanel/advanced/api-shell-for-cpanel)* interface (*cPanel >> Home >> Advanced >> API Shell*) to directly test cPanel API calls.

## Parameters

table
thead
tr
th
Parameter
th
Type
th
Description
th
Possible values
th
Example
tbody
tr
td
code
dir
td
em
string
td
p
The path to the file's directory.
strong
br
td
A valid directory path, relative to the user's 
code
home
 directory.
td
code
public_html/my_directory
tr
td
code
files
td
em
string
td
p
strong
Required
p
The file's name.
td
p
A valid file name.
p
Separate multiple files with the pipe character (
code
|
).
td
code
file.html
## Returns

table
thead
tr
th
strong
Return
th
strong
Type
th
strong
Description
th
strong
Possible values
th
strong
Example
tbody
tr
td
code
mode
td
em
string
td
The file's permissions.
td
A set of file permissions, in 
a
textual representation
 format.
td
code
33188
tr
td
code
file
td
em
string
td
The file's name.
td
A valid filename.
td
code
file.html
tr
td
code
rawmimetype
td
em
string
td
The file's MIME type.
td
A valid MIME type.
td
code
text/html
tr
td
code
nicemode
td
em
integer
td
The file's permissions.
td
A set of file permissions, in 
a
octal notation
 format.
td
code
0777
tr
td
code
size
td
em
integer
td
The size of the file.
td
A positive integer
span
, in bytes
.
td
code
4096
tr
td
code
humansize
td
em
string
td
The formatted size of the file.
td
A positive integer, in megabytes (
code
MB
), kilobytes (
code
KB
), or gigabytes (
code
GB
).
td
code
4 KB
tr
td
code
group
td
em
string
td
The file owner's system group name.
td
A valid group name.
td
code
example
tr
td
code
fullpath
td
em
string
td
p
The absolute path to the file.
td
A valid absolute file path.
td
code
/home/example/public_html/file.html
tr
td
code
user
td
em
string
td
The file owner's system user name.
td
A valid system username.
td
code
example
tr
td
code
ctime
td
em
integer
td
The file's creation time.
td
A 
a
Unix time stamp
.
td
code
1371711650
tr
td
code
uid
td
em
integer
td
The file owner's user ID.
td
p
A valid user ID on the server.
td
code
517
tr
td
code
mtime
td
em
integer
td
The file's last modification time.
td
A 
a
Unix time stamp
.
td
code
1411211655
tr
td
code
mimename
td
em
string
td
The file's MIME name.
td
A valid MIME name.
td
code
text-html
tr
td
code
path
td
em
string
td
p
The absolute path to the file.
td
p
A valid absolute file path.
p
This value does not include the file or directory name.
td
code
/home/example/public_html
tr
td
code
mimeinfo
td
em
string
td
The file's MIME type.
td
A valid MIME type.
td
code
text/html
tr
td
code
rawmimename
td
em
string
td
The file's MIME name.
td
A valid MIME name.
td
code
text-html
tr
td
code
absdir
td
em
string
td
The absolute path to the directory.
td
A valid directory, relative to the account's 
code
/home
 directory.
td
code
home/user/public_html
tr
td
code
type
td
em
string
td
The type of the item.
td
ul
li
code
file
li
code
dir
li
code
char
li
code
block
li
code
fifo
li
code
link
li
code
socket
td
code
file
tr
td
code
gid
td
em
integer
td
The file owner's system group ID.
td
A valid group ID.
td
code
508
tr
td
code
reason
td
em
string
td
p
A reason for failure.
p
This function only returns a 
code
reason
 value if there was an error.
td
span
A string that describes the error.
td
code
This is an error message.
tr
td
code
result
td
em
Boolean
td
p
Whether the function succeeded.
td
ul
li
code
1
 — The function succeeded.
li
code
0
 — The function failed.
td
code
1