AnsweredAssumed Answered

Upload file with curl and php response 404

Question asked by rion on Jul 23, 2018
Latest reply on Jul 23, 2018 by rion

I want upload file with curl and php, but i get response :

{ "status" : { "code" : 404, "name" : "Not Found", "description" : "Requested resource is not available." }, "message" : " No disk space available", "exception" : "", "callstack" : [ ], "server" : "Community v5.0.0 (d r99759-b2) schema 8,022", "time" : "Jul 23, 2018 10:42:37 AM" }

 

And this my code :

$file = "test.txt";$login = 'user';$password = 'password';$postvars = array('filename' => $file,'filedata' => '@'. realpath($file),'siteid'    => 'IT','containerid'   => 'documentLibrary', 'uploaddirectory' =>'/','description' => 'File example','contenttype' => 'cm:content','overwrite' => 'true',);$headers = array(    'Content-Type:multipart/form-data',    'Authorization: Basic '. base64_encode($login.":".$password) // <---); $params_string = '';foreach($postvars as $key=>$value) { $params_string .= $key.'='.$value.'&'; }rtrim($params_string, '&'); $curl_request = curl_init();$url = "http://xxxxxx.com/alfresco/service/api/upload";curl_setopt($curl_request, CURLOPT_URL,$url);curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true);curl_setopt($curl_request, CURLOPT_HTTPHEADER, $headers);curl_setopt($curl_request, CURLOPT_POST,true);curl_setopt($curl_request, CURLOPT_POSTFIELDS,$params_string); $result = curl_exec($curl_request);      echo "<pre>";print_r($result);

i've tried it on postman google chrome and success. But if use curl and php i get error.

I hope someone can help. thank you.

Outcomes