# cPanel API 2 Functions - Fileman::fileop

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 performs an operation on one or more files.

Warning:
We **strongly** recommend that you use [UAPI](/cpanel/introduction/) instead of cPanel API 2. However, no equivalent UAPI function exists.

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=fileop&op=copy&sourcefiles=hot.txt&destfiles=new_directory&doubledecode=1
```

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.

// Perform an operation on a file or group of files.
$fileop = $cpanel->api2(
    'Fileman', 'fileop',
        array(
        'op'                => 'move'
        'sourcefiles'       => 'example.txt,example2.txt'
        'destfiles'         => 'new_directory'
        'doubledecode'      => '1'
    )
);
```

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.

# Perform an operation on a file or group of files.
my $fileop = $cpliveapi->api2(
    'Fileman', 'fileop',
    {
        'op'                => 'move'
        'sourcefiles'       => 'example.txt,example2.txt'
        'destfiles'         => 'new_directory'
        'doubledecode'      => '1'
    }   
 );
```

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 fileop op=move sourcefiles=example.txt,example2.txt destfiles=new_directory doubledecode=1
```

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": "fileop",
    "data": [
      {
        "dest": "/home/example/new_directory",
        "src": "/home/example/example.txt",
        "result": 1
      },
      {
        "dest": "/home/example/new_directory",
        "src": "/home/example/example2.txt",
        "result": 1
      }
    ],
    "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
p
code
op
td
em
string
td
p
strong
Required
p
The operation.
td
ul
li
code
copy
 — Copy the file.
li
code
move
 — Move the file.
li
code
rename
 — Rename the file.
li
code
chmod
 — Change the file's permissions.
li
code
extract
 — Extract the file.
li
code
compress
 — Compress the file.
li
code
link
 — Create a symlink for the file.
li
code
unlink
 — Remove a symlink.
li
code
trash
 — Move the file to the 
code
.trash
 directory.
li
code
restorefile
 — Restore a file from the 
code
.trash
 directory.
td
code
move
tr
td
code
sourcefiles
td
em
string
td
p
strong
Required
p
The files.
td
p
Any valid filename or directory name, relative to the account's 
code
/home
 directory.
p
span
This parameter accepts multiple values as a comma-separated list.
td
code
example.txt,example2.txt
tr
td
code
destfiles
td
em
string
td
p
The files to serve as the destination files for the source files.
p
Use this parameter if you used the 
code
copy
, 
code
move
, or 
code
rename
 operations in the 
code
op
 parameter.
td
p
span
Any valid filename or directory name on the server.
p
This parameter accepts multiple values as a comma-separated list.
td
code
new_directory
tr
td
code
doubledecode
td
em
Boolean
td
p
strong
Required
p
Whether to decode the 
code
sourcefiles
 and 
code
destfiles
 parameters' URI values.
td
ul
li
code
0
 — Do not decode.
li
code
1
 — Decode.
td
code
1
tr
td
code
metadata
td
em
string
td
p
The additional values that the 
code
op
 value's operation requires.
p
For example, if you use the 
code
compress
 operation, use this parameter to pass in the archive type.
td
p
For the 
code
chmod
 operation, use this parameter to pass in the files' octal permissions:
ul
li
code
0755
li
code
0700
p
For the 
code
compress
 operation, use this parameter to pass in the files' archive type:
ul
li
code
zip
li
code
tar.gz
li
code
tar.bz2
li
code
tar
li
code
gz
li
code
bz2
td
code
zip
## Returns

table
thead
tr
th
strong
Return
th
strong
Type
th
strong
Description
th
strong
Possible values
th
strong
Example
tbody
tr
td
code
dest
td
em
string
td
The path to the destination file.
td
The absolute path to a file on the server.
td
code
/home/example/new_directory
tr
td
code
src
td
em
string
td
span
The path from the source file.
td
p
span
The absolute path to a location on the server.
td
code
/home/example/example.txt
tr
td
code
output
td
em
string
td
p
Additional relevant output.
p
This function does not always return an 
code
ouput
 value.
td
A valid string.
td
code
adding: new_directory (stored 0%)
tr
td
code
err
td
em
string
td
p
span
A reason for failure.
p
This function only returns an 
code
err
 value if an error occurred.
p
span
br
td
span
A string that describes the error.
td
code
This is an error message.
br
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