I try to upload a PDF file in Alfresco Enterprise 4. There is my PHP calling curl action :
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, 'http://myalfresco:80/alfresco/service/api/upload?alf_ticket=TICKET_1c75b3391fc2b8a60a1ab92dd1xxx');
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_request, CURLOPT_HEADER, false);
curl_setopt($curl_request, CURLOPT_POST,true);
curl_setopt($curl_request, CURLOPT_POSTFIELDS,array('filedata'=>'@/var/tmp/QDL_Attrib_29.pdf','destination'=>'workspace://SpacesStore/71a79d5f-326d-4671-8fee-5ffef2540e2d'));
$result = curl_exec($curl_request);
And I get this error :
"status" : { "code" : 400, "name" : "Bad Request", "description" : "Request sent by the client was syntactically incorrect." },
"message" : "Required parameters are missing"
If I try to run directly my call in curl in command Line, like this, it works... I don't understand my problem...
curl -v -X POST -F filedata=@/var/tmp/QDL_Attrib_29.pdf -F destination=workspace://SpacesStore/71a79d5f-326d-4671-8fee-5ffef2540e2d http://myalfresco:80/alfresco/service/api/upload?alf_ticket=TICKET_1c75b3391fc2b8a60a1ab92dd1xxx
If I display Header of curl in Command line:
POST /alfresco/service/api/upload?alf_ticket=TICKET_1c75b3391fc2b8a60a1ab92dd1xxx HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: myalfresco
> Accept: */*
> Content-Length: **29447**
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=----------------------------530a6362a7da
In PHP :
POST /alfresco/service/api/upload?alf_ticket=TICKET_1c75b3391fc2b8a60a1ab92dd1xxx HTTP/1.1
Host: myalfresco
Accept: */*
Content-Length: **339**
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------362fa1523053
It mean than curl can get the file with PHP method...