Вот собственно код отправки
<?php //БИЗНЕС ПРОЦЕСС ПОСТИНГА НА КОРПОРАТИВНОМ ПОРТАЛЕ //получаем ID документа для того что бы потом на b2b назвать его именем папку для загружаемых файлов $document_id = '{=Document:ID}' ; $this ->WriteToTrackingService ($document_id ); //Получить ID и путь к допфайлу, если он был прикреплен $file_id = '{=Document:PROPERTY_DOPOLNITELNYE_MATERIALY_B2B_}' ; //7797275 $this ->WriteToTrackingService ('{=Document:PROPERTY_DOPOLNITELNYE_MATERIALY_B2B_}' ); if ($file_id ){$file_path = CFile::GetPath ($file_id ); // /upload/iblock/3dd/image.gif $this ->WriteToTrackingService ($file_path ); //получить имя файла $rsFile = CFile::GetByID ($file_id ); $arFile = $rsFile ->Fetch (); $file_name = $arFile ["FILE_NAME" ]; //image.gif $this ->WriteToTrackingService ($file_name ); //БКП ЗАПРОС НА ПОСТИНГ ФАЙЛА $file = $_SERVER ["DOCUMENT_ROOT" ] . $file_path ; //пусть к файлу на БКП $post = http_build_query(array ('filename' => $file_name , 'path' => 'upload/' . $document_id , 'img' => base64_encode(file_get_contents($file )) //где file это отправляемый файл ) ); $options = array ('http' =>array ('method' => 'POST' , 'header' => 'Content-type: application/x-www-form-urlencoded' , 'content' => $post ) ); //отправляем файл на второй сервер и получаем его ответ $context = stream_context_create($options ); $query = "http://b2bsite.com.ua/api/example/upload/" ; ; $result = file_get_contents($query , false , $context ); $output = json_decode($result ); $this ->WriteToTrackingService ($output ->status . " = " . $output ->result ); }//Получить ID и путь к картинке $picture_id = '{=Document:PREVIEW_PICTURE}' ; //7797275 $this ->WriteToTrackingService ('{=Document:PREVIEW_PICTURE}' ); $picture_path = CFile::GetPath ($picture_id ); // /upload/iblock/3dd/image.gif $this ->WriteToTrackingService ($picture_path ); //получить имя файла $rsPict = CFile::GetByID ($picture_id ); $arPict = $rsPict ->Fetch (); $pict_name = $arPict ["FILE_NAME" ]; //image.gif $this ->WriteToTrackingService ($pict_name ); //БКП ЗАПРОС НА ПОСТИНГ ФАЙЛА $pict = $_SERVER ["DOCUMENT_ROOT" ] . $picture_path ; //пусть к файлу на БКП $post = http_build_query(array ('filename' => $pict_name , 'path' => 'upload/' . $document_id , 'img' => base64_encode(file_get_contents($pict )) //где file это отправляемый файл ) ); $options = array ('http' =>array ('method' => 'POST' , 'header' => 'Content-type: application/x-www-form-urlencoded' , 'content' => $post ) ); //отправляем файл на второй сервер и получаем его ответ $context = stream_context_create($options ); $query = "http://b2bsite.com.ua/api/example/upload/" ; ; $result = file_get_contents($query , false , $context ); $output = json_decode($result ); $this ->WriteToTrackingService ($output ->status . " = " . $output ->result ); //БКП ЗАПРОС НА ПОСТИНГ АКЦИИ //функция транслитерации названия акции function translit ($s ) {$s = (string) $s ; // преобразуем в строковое значение $s = strip_tags($s ); // убираем HTML-теги $s = str_replace(array (" \n " , " \r " ), " " , $s ); // убираем перевод каретки $s = preg_replace("/\s+/" , ' ' , $s ); // удаляем повторяющие пробелы $s = trim($s ); // убираем пробелы в начале и конце строки $s = function_exists('mb_strtolower' ) ? mb_strtolower($s ) : strtolower($s ); // переводим строку в нижний регистр (иногда надо задать локаль) $s = strtr($s , array ('а' =>'a' , 'б' =>'b' , 'в' =>'v' , 'г' =>'g' , 'д' =>'d' , 'е' =>'e' , 'ё' =>'e' , 'ж' =>'j' , 'з' =>'z' , 'и' =>'i' , 'й' =>'y' , 'к' =>'k' , 'л' =>'l' , 'м' =>'m' , 'н' =>'n' , 'о' =>'o' , 'п' =>'p' , 'р' =>'r' , 'с' =>'s' , 'т' =>'t' , 'у' =>'u' , 'ф' =>'f' , 'х' =>'h' , 'ц' =>'c' , 'ч' =>'ch' , 'ш' =>'sh' , 'щ' =>'shch' , 'ы' =>'y' , 'э' =>'e' , 'ю' =>'yu' , 'я' =>'ya' , 'ъ' =>'' , 'ь' =>'' )); $s = preg_replace("/[^0-9a-z-_ ]/i" , "" , $s ); // очищаем строку от недопустимых символов $s = str_replace(" " , "_" , $s ); // заменяем пробелы знаком минус return $s ; // возвращаем результат }$name_actt = <<<EOT {=Document:PROPERTY_NAZVANIE_DLYA_B2B_SAYTA} EOT; $preview_text_up = <<<EOT {=Document:PROPERTY_OPISANIE_DLYA_ANONSA_B2B} EOT; $detail_text = <<<EOT {=Document:PROPERTY_DETALNOE_OPISANIE_B2B} EOT; $code = translit( $name_actt ); $this ->WriteToTrackingService ( $name_actt ); $this ->WriteToTrackingService ('{=Document:PROPERTY_219}'); $this ->WriteToTrackingService ('{=Document:ACTIVE_FROM}'); $this ->WriteToTrackingService ('{=Document:ACTIVE_TO}'); $this ->WriteToTrackingService ( $code ); $this ->WriteToTrackingService ( $preview_text_up ); $db_props = CIBlockElement::GetProperty("55", "{=Document:ID}", array("sort" => "asc"), Array("CODE"=>"DETALNOE_OPISANIE_B2B")); if( $ar_props = $db_props ->Fetch ()){ $detail = $ar_props ["VALUE "]["TEXT"]; } if('{=Document:PROPERTY_219}' == 'Действующая'){ $active = 'Y'; }elseif('{=Document:PROPERTY_219}' == 'Архив'){ $active = 'N'; } $post = http_build_query( array( "name" => $name_actt , "active" => $active , "active_from" => "{=Document:ACTIVE_FROM}", "active_to" => "{=Document:ACTIVE_TO}", "code" => $code ."_" . '{=Document:ID}', "preview_text" => $preview_text_up , "detail_text" => $detail_text , "pictname"=> $pict_name , "filename"=> $file_name , "path"=> "upload/" . $document_id , ) ); $this ->WriteToTrackingService ( $post ); $options = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $post ) ); //отправляем файл на второй сервер и получаем его ответ $context = stream_context_create( $options ); $query = "http://b2bsite.com.ua/example/add_element/" ; $result = file_get_contents( $query , false, $context ); $output = json_decode( $result ); $this ->WriteToTrackingService ( $output ->status . " = " . $output ->result ); $this ->setVariable ('id_on_B2B', $output ->result ); $this ->setVariable ('url_on_B2B',"http://b2bsite.com.ua/shares/" ; . $code . "_" . '{=Document:ID}' . "/");