/**
  * send attachment files to the youtrack
  * @global type $youtrackUrl
  * @param string $issueRef
  * @param array $item
  */
 function stdUserUpdateAttachments($issueRef, $item)
 {
     global $youtrackUrl;
     $getDataFromYoutrack = new getDataFromYoutrack();
     $files = isset($item['attachmentFiles']) ? $item['attachmentFiles'] : null;
     if ($files && ($count = count($files['name']))) {
         for ($i = 0; $i < $count; $i++) {
             if (!strlen($files['name'][$i])) {
                 continue;
             }
             $header = ['Content-Type' => 'multipart/form-data'];
             $body = ['name' => $files['name'][$i], 'file' => '@' . $files['tmp_name'][$i], 'Content-Type' => $files['type'][$i]];
             // POST /rest/issue/{issue}/attachment
             $url = $youtrackUrl . '/rest/issue/' . $issueRef . '/attachment';
             $getDataFromYoutrack->rest($url, 'post', $header, $body);
         }
         $GLOBALS['createByFormAjax'][$issueRef]['attachmentsUpdated'] = true;
     }
 }
<?php

/**
 * download all issues in a project in a csv
 */
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/getCustomSettings.php';
require_once __DIR__ . '/getDataFromYoutrack.php';
require_once __DIR__ . '/authenticationAndSecurity.php';
$getDataFromYoutrack = new getDataFromYoutrack();
$authenticationAndSecurity = new authenticationAndSecurity();
$filename = $authenticationAndSecurity->getPost('filename');
$url = $youtrackUrl . '/rest/export/' . $authenticationAndSecurity->getPost('project') . '/issues';
$res = $getDataFromYoutrack->rest($url, 'get');
$filepath = '../export/' . $filename;
$file = fopen($filepath, "w") or die("Unable to open file!");
fwrite($file, $res);
fclose($file);
chmod($file, $GLOBALS['filePermissions']);
if (file_exists($filepath)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($filepath));
    header('Expires: 1');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($filepath));
    header('Content-type: text/xml');
    readfile($filepath);
    exit;
}