Hello, I’m having trouble uploading an image to an Asana subtask
Do I need to upload the image to my server first?
Here is the code:
$filename = $_FILES['file']['name'];
$curlfinalname = '@' . realpath ($filename);
$curl2 = curl_init();
$data_array2 = '{
"data": {
"file": "'.$curlfinalname.'"
}
}';
$CURLHTTPHeader2 = array(
"Content-Type: multipart/form-data",
'Authorization: Bearer token');
curl_setopt($curl2, CURLOPT_POST, 1);
curl_setopt($curl2, CURLOPT_URL, 'https://app.asana.com/api/1.0/tasks/'.$result_id.'/attachments');
curl_setopt($curl2, CURLOPT_HTTPHEADER, $CURLHTTPHeader2);
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl2, CURLOPT_POSTFIELDS, $data_array2);
$result2 = curl_exec($curl2);
Thank you in advance for your help.