@Brain_code

Как загрузить файл используя Cpanel API Fileman upload_files?

$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...
  • Вопрос задан
  • 41 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы