Skip to content

Commit

Permalink
fixed upload attachment failed - #59
Browse files Browse the repository at this point in the history
  • Loading branch information
lesstif committed Jun 6, 2023
1 parent 6eb2244 commit b54d42c
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/JiraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,32 +302,20 @@ private function createUploadHandle(string $url, string $upload_file, \CurlHandl
// send file
curl_setopt($ch, CURLOPT_POST, true);

if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5) {
$attachments = realpath($upload_file);
$filename = basename($upload_file);
// CURLFile require PHP > 5.5
//$attachments = new \CURLFile(realpath($upload_file));
$attachments = new \CURLFile(realpath($upload_file));
$attachments->setPostFilename(basename($upload_file));

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

$this->log->debug('using legacy file upload');
} else {
// CURLFile require PHP > 5.5
$attachments = new \CURLFile(realpath($upload_file));
$attachments->setPostFilename(basename($upload_file));

curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
['file' => $attachments]
);
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
['file' => $attachments]
);

$this->log->debug('using CURLFile='.var_export($attachments, true));
}
$this->log->debug('using CURLFile='.var_export($attachments, true));

$curl_http_headers = $this->curlPrepare($ch, $curl_http_headers);
$curl_http_headers = $this->curlPrepare($ch, $curl_http_headers, null);

$this->proxyConfigCurlHandle($ch);

Expand Down

0 comments on commit b54d42c

Please sign in to comment.