AnsweredAssumed Answered

Required parameters are missing upload file using Php curl

Question asked by farqalit.nasir on Nov 2, 2017
Latest reply on Nov 3, 2017 by janv

Hi,
I tried all available solutions but failed to upload file because of this error

 

stdClass Object (     [status] => stdClass Object         (             [code] => 400             [name] => Bad Request             [description] => Request sent by the client was syntactically incorrect.         )      [message] => Required parameters are missing     [exception] =>      [callstack] => Array         (         )      [server] => Community v5.2.0 (re21f2be5-b22) schema 10,057     [time] => Nov 2, 2017 12:28:05 PM )


My Code is

 

 

 

$urlws = 'http://' . $user . ':' . $pw . '@' . $server . ':' . $port . '/alfresco/service/api/upload?alf_ticket=' . $ticket;

$postvars = array(
    'filename' => $fileName,
    'filedata' => '@'.realpath($fileName),
    'destination' => $createFolderResponse,
    'uploaddirectory' => '/Fari1',
    'description' => 'File example',
    'contenttype' => 'cm:content',
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_URL, $urlws);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars);
$uploadFileResponse = json_decode(curl_exec($ch));
echo("<pre>");
print_r($uploadFileResponse);exit;

Outcomes