Rohit Garg
Rohit Garg

Reputation: 71

how to create directory in cpanel with the help of cpanel api

I got the class object code which help to create directory in cpanel but the code require a library or a class . name is cpanel.php I need this library or class , Can anyone help me in this ?

I just want to create directory or upload files in cpanel with the help of cpanel api .

here is the url of the cpanel api which help to check the create directory code.

(LiveAPI PHP Class) Thanks in advance , Greater help will be really appreciable!

Upvotes: 1

Views: 629

Answers (1)

jagjeet
jagjeet

Reputation: 377

You need to follow below steps to make dir using cpanel API

    require_once '../components/xmlapi.php';

    $xmlapi = new \xmlapi($cpanel_domain);

    $xmlapi->password_auth($username,$password);

    $xmlapi->set_port(2083);

    $result = $xmlapi->api1_query($password, 'CustInfo', 'getemail', array());   

    if(isset($result->error) && $result->error!=""){
        // error log here
    }

    $api2args = array(
        'path'=> 'public_html',
        'name' => $newdir_name, 
        'permission' => '0755',                     
    );                          
    $result = $xmlapi->api2_query($cpanel_username, 'Fileman', 'mkdir', $api2args);

You can download xmlapi file required for this from here:- https://github.com/CpanelInc/xmlapi-php as its given over here also under developer resources part. https://documentation.cpanel.net/display/SDK/Software+Development+Kit+Home

Upvotes: 2

Related Questions