Skip to content

Instantly share code, notes, and snippets.

@s2ar
Last active June 21, 2016 11:08
Show Gist options
  • Save s2ar/eb167f3c68af9d15231a to your computer and use it in GitHub Desktop.
Save s2ar/eb167f3c68af9d15231a to your computer and use it in GitHub Desktop.
bitrix. Get file info
<?php
function formatBytes($bytes, $precision = 2)
{
$base = log($bytes, 1024);
$suffixes = array('', 'Кбайт', 'Мбайт', 'Гбайт', 'Тбайт');
return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)];
}
if(is_numeric($aProps['cr_pdf']['VALUE'])){
$rFile = CFile::GetByID($aProps['cr_pdf']['VALUE']);
$aFile = $rFile->Fetch();
if($aFile){?>
<a download="<?=$aFile['ORIGINAL_NAME']?>"
href="<?=CFile::GetPath($aProps['cr_pdf']['VALUE'])?>"
>скачать <?=formatBytes($aFile['FILE_SIZE'])?></a><?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment