Your IP : 3.138.181.225
<? if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
\Bitrix\Main\Loader::includeModule('iblock');
if ($_POST['basketElement'] && ($_POST['subaction'] == 'upload')) {
$id = false;
//search element
$element = intval($_POST['basketElement']);
$files = \Webprofy\FileStorage::searchElement($element);
$arResult['ELEMENT'] = array_shift($files);
//Files exists, update Element, or add new Element
if (!empty($_FILES)) {
//Property
$resultProps = array(
'NAME' => 'newElement_' . $element,
"IBLOCK_SECTION_ID" => false,
"IBLOCK_ID" => FILE_STORAGE_IBLOCK_ID,
"PROPERTY_VALUES" => array(
'FILE' => $_FILES['file'],
'BASKET_ITEM_ID' => $element
),
"ACTIVE" => "Y",
);
$oElement = new CIBlockElement();
if ($arResult['ELEMENT']) {
$id = $arResult['ELEMENT']['ID'];
$oElement->Update($id, $resultProps);
} else {
if (!$id = $oElement->Add($resultProps)) {
$errors[] = $oElement->LAST_ERROR;
}
}
}
return $id;
}
//DeleteFile before del BasketElement
if ($_POST['element'] && (intval($_POST['element']) > 0) && ($_POST['subaction'] == 'delete')) {
$arElement = \Webprofy\FileStorage::searchByID($_POST['element']);
if ($arElement) {
return CIBlockElement::Delete($arElement['ID']);
}
return false;
}