R
R
run1822015-08-07 16:28:45
PHP
run182, 2015-08-07 16:28:45

How to fill in a multiple property file in Bitrix?

$arFiles = array();
  for($i = 0; $i < count($_FILES["photo_ar"]['name']); $i++)
  {
    if($_FILES["photo_ar"]['tmp_name'][$i])
      $arFiles[] = array('VALUE' => CFile::MakeFileArray($_FILES["photo_ar"]['tmp_name'][$i]), 'DESCRIPTION' => '');
  }
  $arFields = array(
     "IBLOCK_ID" => 7,
     "NAME" => $head,
     "PROPERTY_VALUES" => array("PHOTO" => $arFiles)
  );
  $oElement = new CIBlockElement();
  $idElement = $oElement->Add($arFields, false, false, true);

Tried it in different ways, even like this - it doesn't work at all :(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
run182, 2015-08-07
@run182

Разобрался, не нужно облекать массив в CFile::MakeFileArray, просто нужно было переопределить многомерный массив в более простой, типа:

$file = Array
                (
                    'name' => $_FILES["photo_ar"]['name'][$i],
                    'size' => $_FILES["photo_ar"]['size'][$i],
                    'tmp_name' => $_FILES["photo_ar"]['tmp_name'][$i],
                    'type' => $_FILES["photo_ar"]['type'][$i]
                );
$arFiles[] = array('VALUE' => $file, 'DESCRIPTION' => '');

Антон Штинов, 2015-08-07
@delimer

А что получается в массиве $arFields? Возможно ошибка в пути к файлу в CFile::MakeFileArray или в правах доступа.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question