$file = 'my_file.php';
$cpanel_host = $this->cPdomain;
$request_uri = "http://$cpanel_host:2083/execute/Fileman/upload_files";
$destination_dir = "public_html";
$payload = array(
'dir' => $destination_dir,
'file-1' => $file
);
// Set up the curl request object.
$ch = curl_init( $request_uri );
curl_setopt( $ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt( $ch, CURLOPT_USERPWD, $this->cPusername . ':' . $this->cPpassword );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
// Set up a POST request with the payload.
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
// Make the call, and then terminate the curl caller object.
$curl_response = curl_exec( $ch );
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
}
curl_close( $ch );
Почему это не работает
Использую док:
https://api.docs.cpanel.net/guides/quickstart-deve...