GetFileArray
mixed CFile::GetFileArray( int FILE_ID, $upload_dir = false )
The method returns an array, describing the file with the specified ID or returns false if the file with such ID does not exist. This method is convenient when both file name and the its path on the server must be retrieved. Static method.
Parameters
Parameter | Description | Available from version |
---|---|---|
FILE_ID | File ID. Fields lineup:
| |
upload_dir | Directory for upload. By default - false. |
See Also
Examples of use
//Show image of the announcement of the information block element
//$ELEMENT_ID - ID of this element
if(CModule::IncludeModule('iblock'))
{
$rsElement = CIBlockElement::GetList(
array(),
array("=ID"=>$ELEMENT_ID),
false,
false,
array("PREVIEW_PICTURE")
);
if($arElement = $rsElement->Fetch())
{
$arFile = CFile::GetFileArray($arElement["PREVIEW_PICTURE"]);
if($arFile)
echo '<img src="'.$arFile["SRC"].'" />';
}
}
Get all file properties from elements of the $arResult
arrayforeach ($arResult["ITEMS"] as $k=>$v) { foreach ($v["PROPERTIES"] as $kk=>$vv) { if ($vv["PROPERTY_TYPE"] == "F") { if ($vv["MULTIPLE"] == "Y") { foreach ($vv["VALUE"] as $kkk=>$vvv) { $arResult["ITEMS"][$k]["PROPERTIES"][$kk]["VALUE"][$kkk] = CFile::GetFileArray($vvv); $arResult["ITEMS"][$k]["PROPERTIES"][$kk]["VALUE"][$kkk]["DESCRIPTION"] = $vv["DESCRIPTION"][$kkk]; } } else { $arResult["ITEMS"][$k]["PROPERTIES"][$kk]["VALUE"] = CFile::GetFileArray($vv["VALUE"]); $arResult["ITEMS"][$k]["PROPERTIES"][$kk]["VALUE"]["DESCRIPTION"] = $vv["DESCRIPTION"]; } } } }
Examples from the component bitrix:news.list
$rsElement = CIBlockElement::GetList($arSort, $arFilter, false, $arNavParams, $arSelect); while($obElement = $rsElement->GetNextElement()) { $arItem = $obElement->GetFields(); ... if(array_key_exists("PREVIEW_PICTURE", $arItem)) $arItem["PREVIEW_PICTURE"] = CFile::GetFileArray($arItem["PREVIEW_PICTURE"]); if(array_key_exists("DETAIL_PICTURE", $arItem)) $arItem["DETAIL_PICTURE"] = CFile::GetFileArray($arItem["DETAIL_PICTURE"]); ... }
© «Bitrix24», 2001-2024