From b54d42c723e9ce760869a72a517cf12a3125c5a9 Mon Sep 17 00:00:00 2001 From: KwangSeob Jeong Date: Wed, 7 Jun 2023 00:22:13 +1000 Subject: [PATCH] fixed upload attachment failed - #59 --- src/JiraClient.php | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/JiraClient.php b/src/JiraClient.php index 1d1587a..d6d43b7 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -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);