legacy-api-documentation icon indicating copy to clipboard operation
legacy-api-documentation copied to clipboard

picture upload via php

Open albertmgh opened this issue 6 years ago • 0 comments

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;     
}

albertmgh avatar Mar 12 '18 10:03 albertmgh