legacy-api-documentation
legacy-api-documentation copied to clipboard
picture upload via php
Hallo, i'm trying to upload a photo and read the documentation that describes the two steps flow. In the first step im getting the code 200 and all necessary data to post the second step.
please tell me how to add the data to the curl request ...
here is my code
public function sendPhotoRequest($filename){
$this->response = $this->connection->post(self::URL, $this->parameters);
if (function_exists('curl_file_create')) {
$cFile = curl_file_create($filename, 'image/jpeg');
} else { //
$cFile = '@' . realpath($filename);
}
require_once ROOTDIR.'/utils.php';
$post = objectToArray($this->response->presigned_post->fields);
$header = array("Content-Type:multipart/form-data");
$post['file'] = $cFile;
$this->response = $this->connection->post($this->response->presigned_post->url, $post, $header);
return $this;
}