Skip to content

Commit b54d42c

Browse files
committed
fixed upload attachment failed - #59
1 parent 6eb2244 commit b54d42c

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

src/JiraClient.php

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -302,32 +302,20 @@ private function createUploadHandle(string $url, string $upload_file, \CurlHandl
302302
// send file
303303
curl_setopt($ch, CURLOPT_POST, true);
304304

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

309-
curl_setopt(
310-
$ch,
311-
CURLOPT_POSTFIELDS,
312-
['file' => '@'.$attachments.';filename='.$filename]
313-
);
314-
315-
$this->log->debug('using legacy file upload');
316-
} else {
317-
// CURLFile require PHP > 5.5
318-
$attachments = new \CURLFile(realpath($upload_file));
319-
$attachments->setPostFilename(basename($upload_file));
320-
321-
curl_setopt(
322-
$ch,
323-
CURLOPT_POSTFIELDS,
324-
['file' => $attachments]
325-
);
310+
curl_setopt(
311+
$ch,
312+
CURLOPT_POSTFIELDS,
313+
['file' => $attachments]
314+
);
326315

327-
$this->log->debug('using CURLFile='.var_export($attachments, true));
328-
}
316+
$this->log->debug('using CURLFile='.var_export($attachments, true));
329317

330-
$curl_http_headers = $this->curlPrepare($ch, $curl_http_headers);
318+
$curl_http_headers = $this->curlPrepare($ch, $curl_http_headers, null);
331319

332320
$this->proxyConfigCurlHandle($ch);
333321

0 commit comments

Comments
 (0)