I'm using the following code to generate a filesize for a linked file:
Code: Select all
<?php
$file_type = array( 'K', 'M', 'G' );
$size = filesize ( $f );
for ( $t = 0; $size > 1024; $t++ )
{
$size /= 1024;
$file_size = round ( $size, 1 ) . ' ' . $file_type[ $t ] . 'B';
}
$file_name = substr($f, -(strlen($f) - strrpos($f,'/')));
echo "<a href=\"$f\" class=\"pdf\" title=\"$file_size\">";
list($f, $ext) = explode('.', $f);
echo basename($f);
echo " <small>($file_size)</small></a>";
?>Code: Select all
<?php $f = "My Event.pdf";?>Code: Select all
<a href="My Event.pdf" class="pdf" title="82 KB">My Event<small>(82 KB)</small></a>
Code: Select all
Watch out for [u]My Event (82 KB)[/u] - the vital source of LOCAL information. [u]Click here for more information[/u].
Code: Select all
Watch out for - the vital source of LOCAL information. [u]Click here for more information[/u].
My Event (82 KB)Thanks,
Mark