diff --git a/src/Collection.php b/src/Collection.php index d931373..69db14c 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -47,6 +47,32 @@ class Collection return json_decode($response, JSON_FORCE_OBJECT); } + /** + * @param string $recordId + * @param string $field + * @param string $filepath + * @return void + */ + public function upload(string $recordId, string $field, string $filepath): void + { + $ch = curl_init($this->url . "/api/collections/gallery_media/records/" . $recordId); + curl_setopt_array($ch, array( + CURLOPT_CUSTOMREQUEST => 'PATCH', + CURLOPT_POSTFIELDS => array( + $field => new \CURLFile($filepath) + ) + )); + + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + $headers = array('Content-Type: multipart/form-data'); + + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + $response = curl_exec($ch); + // var_dump($response); + } + /** * @param string $email * @param string $password