Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


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

How to attach the file in issue in PHP

I am using Laravel framework (PHP) - I can able to create issue or task using Rest API V3 and its created successfully, but when try to add the attachment for that particular issue or task using [ISSUE-KEY] i can't able to attache the files. In the API Reference documentation there is no proper sample codes. I am using CURL to attach or create the issue.

Can anyone please suggest me to get this done. Below having my code

$chcurl_init ();   

$username = "XXXX-XXX-XXX" ;

$pasword = "*********";

$path = "filepath.txt";                
$url = ''.$result['key'].'/attachments';      

curl_setopt ( $ch, CURLOPT_URL, $url );                    

curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );                                        

curl_setopt ( $ch, CURLOPT_POSTFIELDS, ['file'=>'@'.realpath($path) ]);                    

curl_setopt ( $ch, CURLOPT_POST, 1 );                   

 $headers = array ();                    

$headers [] = 'X-Atlassian-Token: no-check';                                      

curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers );                    

curl_setopt ( $ch, CURLOPT_USERPWD, $username . ":" . $password );                    

$Arr = [];                    

$resultt = curl_exec ( $ch);                    

2 answers

Thanks for your suggesstion Ravi Sagar. Will convert above CURL to PHP and let me try. 

0 votes
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 22, 2021

Hi @yasmeen banu 

You have to use the multipart/form-data for sending the file. I once wrote a small Drupal module to upload files in Jira but I can't find a simple php example. However let me share my shell script.

#! /bin/bash

curl -s -i -X POST \
     -H "Authorization:Basic $JIRATUTORIAL_AUTH" \     -H "X-Atlassian-Token:no-check" \     -F "file=@/home/ravisagar/jiraissues.csv" \     '' \

Try this in your shell and if it works then hopefully you will get an idea about what headers to pass. I believe there should be libraries in PHP to do this for you (my PHP skills are fading :( sorry).

I hope it helps.


I have tried with multipart/form-data in header but no luck. @Ravi Sagar _Sparxsys_ 

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events