# FileManager API: curl\_exec displays objects

**URL:** <https://community.hubspot.com/t/filemanager-api-curl-exec-displays-objects/52737>\
**Category:** APIs & Integrations\
**Created:** [March 8, 2022, 4:19pm UTC](https://community.hubspot.com/t/filemanager-api-curl-exec-displays-objects/52737 "2022-03-08T16:19:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Compounder](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/compounder/32/52876_2.png) [@Compounder](https://community.hubspot.com/u/Compounder)\
**Post date:** [March 8, 2022, 4:19pm UTC](https://community.hubspot.com/t/filemanager-api-curl-exec-displays-objects/52737/1 "2022-03-08T16:19:29Z")

</div>

Hey guys!

I just ran into the following problem: I am using the FileManager API in order to upload documents which ultimately will be connected to a contact ([https://legacydocs.hubspot.com/docs/methods/files/v3/upload\_new\_file](https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file)). For this, I am using **PHP 7.4** , following precisely the instructions given in the above-mentioned page. For whatever reason, the **$response = @curl\_exec($ch);** leads to the object being displayed on the screen, instead of being stored in the variable:

 ![Bildschirmfoto 2022-03-08 um 17.17.52.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/a/ae2d8d825fc8eabc8f5f08297ed3bc9ee6d92eb5.png)

Hence, I cannot json\_decode the response and also not use the information at all; in the end, I just require the friendly URL to attach it to contact.

Does anybody know why this is the case? As far as I know, it worked fine beforehand (I used the same code some time last year). Thank you very much in advance for your help!

All the best,

Mino.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [March 9, 2022, 4:29pm UTC](https://community.hubspot.com/t/filemanager-api-curl-exec-displays-objects/52737/2 "2022-03-09T16:29:33Z")

</div>

@RMones , curious if you have had a similar issue 👀

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [March 9, 2022, 7:05pm UTC](https://community.hubspot.com/t/filemanager-api-curl-exec-displays-objects/52737/3 "2022-03-09T19:05:23Z")

</div>

Hi @dennisedson and @Compounder ,

There is a paramter missing in the example for getting the data in the variable instead of the stdout..

> **[PHP: curl\_setopt - Manual](https://www.php.net/manual/en/function.curl-setopt.php)**
>
> Set an option for a cURL transfer

CURLOPT\_RETURNTRANSFER  
true to return the transfer as a string of the return value of curl\_exec() instead of outputting it directly.  
So if you add the following line:

`@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);`

after

`@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);`

The data will be passed to the variable!  
Good luck.

Regards Ronald

---

<div class="post-metadata">

**Author:** ![Compounder](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/compounder/32/52876_2.png) [@Compounder](https://community.hubspot.com/u/Compounder)\
**Post date:** [March 10, 2022, 8:28am UTC](https://community.hubspot.com/t/filemanager-api-curl-exec-displays-objects/52737/4 "2022-03-10T08:28:36Z")

</div>

Oh my, could have found that on my own when just scrolling down within my own script, where I am doing the cURL for the ContactAPI 😄 cheers, Ronald!
