Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $url = 'https://domain.atlassian.net/rest/api/2/issue/PL-113/attachments';
- $fileLocation = 'D:/xampp/htdocs';
- $fileName = 'test.jpg';
- $username = 'username';
- $password = 'password';
- $data = array('file'=>"@{$fileLocation};filename={$fileName}");
- $headers = array(
- 'X-Atlassian-Token: nocheck'
- );
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($curl, CURLOPT_VERBOSE, 1);
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
- $result = curl_exec($curl);
- $ch_error = curl_error($curl);
- if ($ch_error) {
- echo "cURL Error: $ch_error";
- } else {
- echo $result;
- }
- curl_close($curl);
Add Comment
Please, Sign In to add comment