I'm having trouble with the second step of uploading a post with a photo seen here.
$post_fields = array(
'file' => '@' . $_FILES['file-attachment']['tmp_name']
. ';filename=' . $_FILES['file-attachment']['name']
. ';type=' . $_FILES['file-attachment']['type']
);
$upload_response = process_curl(array(
CURLOPT_URL => $upload_url,
CURLOPT_HEADER => false,
CURLOPT_TIMEOUT => 10,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POSTFIELDS => $post_fields,
CURLOPT_HTTPHEADER => array('Authorization: Bearer '.$token, 'x-li-format: json','Content-Type: multipart/form-data'),
), true);
This is what my request looks like. I tried without using the type=
line but that didn't change anything. I'm getting an empty response and a status code of 400.
I'm using the upload URL from step 1 so I know that should be correct.
What about my request looks wrong? I'm trying to follow the cURL example they gave in the documentation, but perhaps the format of my file isn't correct?
I have also tried making the file parameter of post fields just be the full file path but that gave a response of false.
Another thing for me to mention is the file path has spaces in it.