R
R
run1822018-02-07 18:49:27
1C-Bitrix
run182, 2018-02-07 18:49:27

How to update the File multiple property of an element in Bitrix?

$el = new CIBlockElement;
$arLoadProductArray = Array(
    "PROPERTY_VALUES"=> array(
        "PHOTOS" => array(
            ($_FILES["PHOTO_1"]["size"] == 0) ? CFile::MakeFileArray($arCard["PROPS"]["PHOTOS"]["VALUE"][0]) : $_FILES["PHOTO_1"],
            ($_FILES["PHOTO_2"]["size"] == 0) ? CFile::MakeFileArray($arCard["PROPS"]["PHOTOS"]["VALUE"][1]) : $_FILES["PHOTO_2"]
        )
    )
);
$res = $el->Update($arCard["FIELDS"]["ID"], $arLoadProductArray);

Thus, the files are only added to the existing ones, but how can they be overwritten or even clear the property?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danbka, 2018-02-07
@Danbka

Firstly, see how to work with a multiple property of the "File" type here: https://dev.1c-bitrix.ru/learning/course/index.php...
Secondly, I will add from myself that not specified in the documentation: to add a new file without deleting the old ones, use the CIBlockElement::SetPropertyValueCode method, not CIBlockElement::SetPropertyValuesEx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question