XML-RPC File upload

Re: XML-RPC File upload

by James Taylor -
Number of replies: 0
Hi Rimphy, I picked up this old post as I needed some help with core_files_upload. I am using the CURL client and keep on getting error in parameter signature. Can you please help me out with what is the exact parameter which needs to be passed. I am including the script I am using:


?php
error_reporting(E_ALL);
ini_set('display_errors', true);

$domainname = 'http://localhost:8888/moodle27';
$authToken = '78a911fae46c14b3cd36d3651f7f0c9d';

header('Content-Type: text/plain');
$serverurl = $domainname . '/webservice/xmlrpc/server.php'. '?wstoken=' . $authToken;
require_once('./curl.php');
$curl = new curl;


$functionname = 'core_files_upload';


$params1 = array( 'contextid'  => 30,
                 'component'    => 'user',
                 'filearea'     => 'draft',
                 'itemid'       => 0,
                 'filepath'     => "/",
                 'filename'     => "for-upload.txt",
                 'filecontent'  => base64_encode("upload third moodle file")  ,
                 'contextlevel' => null ,
                 'instanceid' => 1 );



$post = xmlrpc_encode_request($functionname, $params1);
$resp = xmlrpc_decode($curl->post($serverurl, $post));

print_r($resp);