[spoiler]
<? function UploadPicture($id=1) { if (CModule::IncludeModule('iblock')) { $IBLOCK_ID = 63; $arSelect = Array("ID", "IBLOCK_ID", "NAME", "DETAIL_PICTURE", "PROPERTY_LINK_PHOTO"); $arFilter = Array("IBLOCK_ID" => intval($IBLOCK_ID), '>ID' => $id, '!PROPERTY_LINK_PHOTO'=>false, "DETAIL_PICTURE"=>false); $res = CIBlockElement::GetList(Array("ID" => "ASC"), $arFilter, false, Array("nPageSize" => 100), $arSelect); $select_counte = $res->SelectedRowsCount(); if ($select_counte < 1) { return false; }else { while ($ob = $res->GetNextElement()) { $arFields = $ob->GetFields(); $pic = CFile::MakeFileArray($arFields["PROPERTY_LINK_PHOTO_VALUE"]); $el = new CIBlockElement; $arLoadProductArray = Array( "DETAIL_PICTURE" => $pic ); $res_pic = $el->Update($arFields['ID'], $arLoadProductArray); if(!$res_pic) echo '<pre>', print_r($el->LAST_ERROR), '</pre>' ; unset($pic); $new_id = $arFields["ID"]; } return "UploadPicture(".$new_id.");"; } }else{ return false; } } ?> <?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?> |