Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

API Upload attachments with PHP + cURL


Hi! i'm developing an page who is capable to create a new card using some input/select, and i'm trying to create an input type="file" multiple.

Everything is working except upload, i'm using an ajax call using javascript to send the file to one PHP called ajaxResponse.php who is responsible to create a new card and upload the attachments, my doubt is:

- The multiple files is working fine and creating the attachments in the card ie already created, however, the files in trello when the ajax call is done, instead of showing me the right file with the correct extension, the attachment always have 19 bytes, and create an filename which name is Upload, if i download this file and check the content with one text editor, the content of this file is the filename i uploaded in HTML, can anybody tell me how was the correctly way to host a file using API + PHP+ cURL, please?

my Codes:



var files = document.getElementById('anexoTrello').files;

var formData = new FormData();

for(i = 0; i < myFiles.length; i++){

  formData.append('file[]', myFiles[i]);


var ajax = new XMLHttpRequest();'POST', 'assets/php/ajaxResponse.php');





  for ($i=0; $i < count($_FILES['file']['name']); $i++) {
    $chAttachment = curl_init();
    curl_setopt($chAttachment, CURLOPT_URL, '');
    curl_setopt($chAttachment, CURLOPT_POSTFIELDS, http_build_query(
        'name' => $_FILES['file']['name'][$i],
        'file' => $_FILES['file']['tmp_name'][$i]

    curl_setopt($chAttachment, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec($chAttachment);

    curl_close($chAttachment); print_r($result);




1 answer

0 votes
Lara Atlassian Team Nov 08, 2021

Hi Ricardo,

Thanks for reaching out!

This would be a really great question to share in our developer community. We have a number of Trello Engineers that are active there, and they'd be happy to give some guidance for more advanced topics like these.

Also, if it helps, there have been some changes made to how users can access attachments via the API, discussed further here:

Please let us know if you have any other questions, and we'll be happy to help.

All the best,

The Trello Team

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Trello

Taco Tuesday: New years' resolutions with Trello

Congratulations to @Laura Holton , our latest winner of Taco Tuesday! And thanks to @Kristján Geir Mathiesen for sharing the picture of Taco having fun with his new friend  B...

2,399 views 28 41
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you