Last active
June 21, 2016 11:08
-
-
Save s2ar/eb167f3c68af9d15231a to your computer and use it in GitHub Desktop.
bitrix. Get file info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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