UAPI Functions - Fileman::upload_files

Description

This function uploads files.

Examples


 cPanel or Webmail Session URL

https://hostname.example.com:2083/cpsess##########/execute/Fileman/upload_files?dir=/home/user/public_html&file-1=example.html&file-2=rankand.html

 LiveAPI PHP Class

$cpanel new CPANEL(); // Connect to cPanel - only do this once.
  
// Upload files to public_html directory.
$upload_files $cpanel->uapi(
    'Fileman''upload_files',
        array(
        'dir'               => '/home/user/public_html',
        'file-1'            => 'nail.html',
        'file-2'            => 'rankand.html',
         )
);

 LiveAPI Perl Module

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
  
# Upload files to public_html directory.
my $ upload_files = $cpliveapi->uapi(
    'Fileman''upload_files',
        {
        'dir'               => 'public_html',
        'file-1'            => 'nail.html',
        'file-2'            => 'rankand.html',  
         }
 );

 cPanel Template Toolkit

<!-- Get a hash of all the data, then display the uploads value. -->
[% data = execute( 'Fileman', 'upload_files' {dir => 'public_html, 'file' => 'example.html' ); %]
[% FOREACH q = data.prefix %]
     <p>
         [% q %]
     </p>
[% END %]
  
<!-- Get only a hash of the data. -->
[% execute('Fileman', 'upload_files' {dir => 'public_html, 'file-1' => 'nail.html', 'file-2' => 'rankand.html'}  ).data.uploads %]

 Command Line

uapi --user=username Fileman upload_files dir=%2Fhome%2Fusername%2Fpublic_html file-1=example.html file-2=rankand.html

 

Notes:

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

 Output (JSON)

   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{ 
 
  },
  "data": {
    "uploads": [
      nail.html
      rankand.html 
    ],
    "succeeded": 2,
    "warned": 0,
    "failed": 0
  }
}

 

Note:

Use cPanel's API Shell interface (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

 Parameters

Type

Description

Possible values

Example

dir

 string 

 Required

 The directory to which to upload the files.

 A valid directory on the server, relative to the user's home directory. 

 public_html 

file-*

string

Required

The files to upload.

Important:

  • You must pass this parameter for each file to upload.
  • You must increment each variable. For example, pass the first file as file-1 and the second file as file-2. 

A valid filename on the server.

nail.html

 

Returns

Return

Type

Description

Possible values

Example

uploads

array

 A list of files that uploaded to the specified directory. 

 A list of upload files. 

 example.html 

 succeeded 

 integer 

The number of files that uploaded successfully.

A positive integer.

1

warned

 integer 

The number of files that did not fully upload.

A positive integer.

0

failed

 integer 

The number of files that failed to upload.

A positive integer.

0

 

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