Hello All
Is there anyone who can help regarding the error
Here is my code
if(isset($_POST['submit'])){
$imagename = $_FILES["image"]["name"];
$params = array('component' => 'user','filearea' => 'draft', 'itemid' => 0,'filename' => $imagename,'filepath' => '/','filecontent' => base64_encode($imagename), 'contextlevel' => 'user', 'instanceid' =>2);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url . '/webservice/rest/server.php?wstoken='.$token.'&wsfunction=core_files_upload&moodlewsrestformat=json');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch);
$result=json_decode($response, true);
//echo $result['itemid'];
//print_r($result);
$params2 = array( 'draftitemid' => $result['itemid'],'userid' => 385217);
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_HEADER, 0);
curl_setopt($ch2, CURLOPT_VERBOSE, 0);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_URL, $url . '/webservice/rest/server.php?wstoken='.$token.'&wsfunction=core_user_update_picture&moodlewsrestformat=json');
curl_setopt($ch2, CURLOPT_POST, true);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $params2);
$response2 = curl_exec($ch2);
print_r($response2);
}
Output showing this
{"success":false,"warnings":[]}
Thanks
Deepak