Questions and discussion about using ProcessMaker: user interface, running cases & functionality
#827449
I am unable to upload a single file or multiple files in processmaker .
I referred the documentations listed below:
https://wiki.processmaker.com/3.0/REST_ ... t-document
https://sourceforge.net/p/pmcommunity/c ... _uidupload
But when I call the api to upload file the request returns with error code 0.
Also the $oResponse returns null.
Here is my code:
Code: Select all
<?php
$inputDocId = '2699784865e2155c3e04a43081494049';
$taskId     = '6255531755e0dff921e5466035447157';
$caseId     = '2992109955e26871503f671072958707';
$url        = "http://workflow.rest.com:8805/api/1.0/workflow/cases/$caseId/input-document";
$nFiles = count($_FILES['file']['name']);
$access_token = '3a21f7a2e052d1ad31a91fb24deb50da8a5d9196';


for ($i = 0; $i < $nFiles; $i++) {
   $path = $_FILES['file']['tmp_name'][$i];
   $type = $_FILES['file']['type'][$i];
   $filename = $_FILES['file']['name'][$i];
   //rename file from temp name to real name:
   rename($path, sys_get_temp_dir() .'/'. $filename); //reverse \ for windows systems

   $aVars = array(
      'inp_doc_uid'     => $inputDocId,
      'tas_uid'         => $taskId,
      'app_doc_comment' => '',
      'form'            => (phpversion() >= "5.5") ? new CurlFile($path, $type) : '@'.$path
   );


   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, $url);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $access_token));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $aVars);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   $oResponse = json_decode(curl_exec($ch));  // returns null in my case.
   $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
   curl_close($ch);
//    unlink(sys_get_temp_dir() .'/'. $filename); //delete file

    if ($httpStatus == 200) {
        print "File ". $oResponse->app_doc_uid ." uploaded.\n";
    }
    elseif (is_object($oResponse) and isset($oResponse->error)) {
        print "Error code: {$oResponse->error->code}\n" .
            "Message: {$oResponse->error->message}\n";
    }
    else {
        print "Error code: $httpStatus";
    }

}
?>
I have also tried uploading file using the endpoint mentioned in the link below.
https://sourceforge.net/p/pmcommunity/c ... _uidupload
Still it returns with same errors as mentioned in the above method.

Also I am using the extraRest plugin version 1.13
please help me out asap.

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]