$fileId = 123; // replace with actual file ID $file = CFile::GetByID($fileId); if ($arFile = $file->Fetch()) { echo $arFile["SRC"]; // output the file URL }
$fileId = 456; // replace with actual file ID $file = CFile::GetByID($fileId); if ($arFile = $file->Fetch()) { header("Content-type: {$arFile['CONTENT_TYPE']}"); header("Content-Disposition: attachment; filename={$arFile['ORIGINAL_NAME']}"); echo $arFile['CONTENT']; // output the file content for download }This example retrieves a file by its ID and outputs the file content for download, along with setting the appropriate headers. The CFile class is part of the Bitrix Framework, which is a package library for PHP.