Похожие чаты

Добрый день! Коллеги никак не пойму как закинуть в

поле сделки файл
$dealId = 1258; // ID сделки
$uploadFolder = './upload'; // Путь к папке с файлами для загрузки

$filesInFolder = scandir($uploadFolder); // Получаем список файлов в папке

$batchUpdate = array();

foreach ($filesInFolder as $fileName) {
if ($fileName !== '.' && $fileName !== '..') {
$filePath = $uploadFolder . '/' . $fileName;
$fileContent = base64_encode(file_get_contents($filePath));

$batchUpdateItem = array(
'update_deal_' . $fileName => 'crm.deal.update?' . http_build_query(
array(
'id' => $dealId,
'fields' => array(
'UF_CRM_1693238467' => array(
$fileName, $fileContent,
)
),
)
)
);

$batchUpdate = array_merge($batchUpdate, $batchUpdateItem);
}
}

$resultUpdate = executeHook(array('cmd' => $batchUpdate));

function executeHook($params)
{
global $webhookUrl;

$queryUrl = $webhookUrl . 'batch.json';
$queryData = http_build_query($params);

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_POST => 1,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $queryUrl,
CURLOPT_POSTFIELDS => $queryData,
));

$result = curl_exec($curl);
curl_close($curl);
var_dump($result);
return json_decode($result, true);
}

if (isset($resultUpdate['result'])) {
echo "Файлы успешно загружены в сделку!";
} else {
echo "Ошибка загрузки файлов: " . $resultUpdate['error_description'];
}


смотрел как делать тут 💪 https://dev.1c-bitrix.ru/rest_help/crm/cdeals/crm_deal_update.php

есть пример 👍
Как через веб хук загрузить файл в сделку (PHP)

$batchUpdate = array (
'update_contact' => 'crm.deal.update?'.http_build_query(
array(
'id'=> $dealId,
'fields'=> array(
'fileData'=>array(
$files['files']['name'], base64_encode(file_get_contents($files['files']['tmp_name'])),
)
),
)
)
)
$resultUpdate = executeHook(array('cmd' => $batchUpdate)); // выполняем хук

11 ответов

25 просмотров
Денис-Ковалевский Автор вопроса

Помогите пожалуйста

Так что непонятно-то?

Денис-Ковалевский Автор вопроса
Eugene Zhukov
Так что непонятно-то?

файлик не аплодится

Ошибка какая?

Денис-Ковалевский Автор вопроса
Eugene Zhukov
Ошибка какая?

string(566) "{"result":{"result":{"update_deal_1693237425.jpg":true},"result_error":[],"result_total":[],"result_next":[],"result_time":{"update_deal_1693237425.jpg":{"start":1693250273.164426,"finish":1693250273.253406,"duration":0.08897995948791504,"processing":0.08889889717102051,"date_start":"2023-08-28T22:17:53+03:00","date_finish":"2023-08-28T22:17:53+03:00"}}},"time":{"start":1693250273.140987,"finish":1693250273.253422,"duration":0.11243510246276855,"processing":0.08973217010498047,"date_start":"2023-08-28T22:17:53+03:00","date_finish":"2023-08-28T22:17:53+03:00"}}" Файлы успешно загружены в сделку!

Денис-Ковалевский Автор вопроса
Eugene Zhukov
А поле правильное?

/fields/CRM_DEAL/edit/UF_CRM_1693238467/

Денис-Ковалевский Автор вопроса

@mcp74 прошу совет или лучше пример как закинуть файл в поле ФАЙЛ 😀

Денис-Ковалевский Автор вопроса
Alexander Ostrovsky
Не

та понятно, потому-что поздно уже

Денис-Ковалевский Автор вопроса
Alexander Ostrovsky
Не

уже вдруг спать захотелось

Похожие вопросы

Обсуждают сегодня

А еще в перле можно уже @arr1 + @arr2?
Sergei Zhmylove
53
я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
100
Привет всем. появился вопрос. Разрабатываю сайт, в данный момент он запущен. Хостинг beget. Добавляю на сайт яндекс метрику с помощью полей client-settings (взято отсюда http...
Andrew
2
I arrived here after a Chico Crypto show highlighted the project & the Team - the fact that the Team had a long history of successfully working with household names gave me e...
Banter is Bullish
1
Подскажите, где смотреть результат выполнения программы? Код: ;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, станда...
Егор Анелькин
5
Где в Астане можно купить мясо для шашлыков?
Dancing Іңұқәһүғө
21
Morning people Just seeing the conversation about Mining. It's clear that at this point in time it doesn't look like there is much point to it. But the Hasrate is at a al...
Kenny
2
;.686 ;Система команд процессора 686 ;.MODEL FLAT,stdcall ;Модель памяти плоская, стандартный ;вызов процедуры ;option casemap:no...
Егор Анелькин
1
Hi I have recently invested in ewt . Any way to stake it ?
K ì V
11
Добрый день подскажите пожалуйста может кто то сталкивался с ошибками Sentry 22.10.0 развернутым из helm чарт в Kubernetes? Изначально 3 дня назад очень стало много событий ух...
Tire4 Finist Devops
1
Карта сайта