<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP File Last Modified and Filesize (bytes to KB/MB)</title>
	<atom:link href="http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/</link>
	<description></description>
	<lastBuildDate>Sun, 08 Jan 2012 10:37:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Pete west</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-6068</link>
		<dc:creator>Pete west</dc:creator>
		<pubDate>Sat, 22 Oct 2011 11:48:29 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-6068</guid>
		<description>I actually found another code as well, this one autodetects which file size to use (KB/MB/GB)

  function calc($size) {
    $kb=1024;
    $mb=1048576;
    $gb=1073741824;
    $tb=1099511627776;
    if(!$size)
      return &#039;0 B&#039;;
    elseif($size&lt;$kb)
      return $size.&#039; B&#039;;
    elseif($size&lt;$mb)
      return round($size/$kb, 2).&#039; KB&#039;;
    elseif($size&lt;$gb)
      return round($size/$mb, 2).&#039; MB&#039;;
    elseif($size&lt;$tb)
      return round($size/$gb, 2).&#039; GB&#039;;
    else
      return round($size/$tb, 2).&#039; TB&#039;;
  }

All I need to know is how to make it work (how do I make that code display a files size?)</description>
		<content:encoded><![CDATA[<p>I actually found another code as well, this one autodetects which file size to use (KB/MB/GB)</p>
<p>  function calc($size) {<br />
    $kb=1024;<br />
    $mb=1048576;<br />
    $gb=1073741824;<br />
    $tb=1099511627776;<br />
    if(!$size)<br />
      return &#8217;0 B&#8217;;<br />
    elseif($size&lt;$kb)<br />
      return $size.&#039; B&#039;;<br />
    elseif($size&lt;$mb)<br />
      return round($size/$kb, 2).&#039; KB&#039;;<br />
    elseif($size&lt;$gb)<br />
      return round($size/$mb, 2).&#039; MB&#039;;<br />
    elseif($size&lt;$tb)<br />
      return round($size/$gb, 2).&#039; GB&#039;;<br />
    else<br />
      return round($size/$tb, 2).&#039; TB&#039;;<br />
  }</p>
<p>All I need to know is how to make it work (how do I make that code display a files size?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pete west</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-6067</link>
		<dc:creator>Pete west</dc:creator>
		<pubDate>Sat, 22 Oct 2011 06:25:20 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-6067</guid>
		<description>This is great, exactly what I have been looking for.
With Erick Levy&#039;s code, I&#039;m quite new with PHP, do I have to make a seperate functions.php file with that code in it? How does it exactly work?</description>
		<content:encoded><![CDATA[<p>This is great, exactly what I have been looking for.<br />
With Erick Levy&#8217;s code, I&#8217;m quite new with PHP, do I have to make a seperate functions.php file with that code in it? How does it exactly work?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-5946</link>
		<dc:creator>john</dc:creator>
		<pubDate>Tue, 28 Jun 2011 17:28:20 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-5946</guid>
		<description>thanks for letting me know - it&#039;s been fixed</description>
		<content:encoded><![CDATA[<p>thanks for letting me know &#8211; it&#8217;s been fixed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-5945</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Sun, 26 Jun 2011 20:44:48 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-5945</guid>
		<description>Actually there is a typo in the code. In the round function the variable should be $filesize and not $file.
So the correct code should be:

&lt;code&gt;
$file_kb = round(($filesize / 1024), 2); // bytes to KB  ...
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Actually there is a typo in the code. In the round function the variable should be $filesize and not $file.<br />
So the correct code should be:</p>
<p><code><br />
$file_kb = round(($filesize / 1024), 2); // bytes to KB  ...<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erick Levy</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-5943</link>
		<dc:creator>Erick Levy</dc:creator>
		<pubDate>Wed, 22 Jun 2011 02:04:48 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-5943</guid>
		<description>How about using a function to return the filesize in the desired units or automatic mode:

&lt;code&gt;
function file_size($file,$unit=&#039;auto&#039;) {
	$retval = false;
	if (file($file)) {
		$filesize = filesize($file);
		if ($unit == &#039;GB&#039; &#124;&#124; $unit == &#039;auto&#039; &amp;&amp; $filesize &gt;= pow(1024,3)) {
			$retval = round(($filesize / pow(1024,3)),2) . &#039;GB&#039;;
		} elseif ($unit = &#039;MB&#039; &#124;&#124; $unit == &#039;auto&#039; &amp;&amp; $filesize &gt;= pow(1024,2)) {
			$retval = round(($filesize / pow(1024,2)),2) . &#039;MB&#039;;
		} elseif ($unit = &#039;KB&#039; &#124;&#124; $unit == &#039;auto&#039; &amp;&amp; $filesize &gt;= 1024) {
			$retval = round(($filesize / 1024),2) . &#039;KB&#039;;
		} else {
			$retval = $filesize . &#039;Bytes&#039;;
		}
	}
	return $retval;
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>How about using a function to return the filesize in the desired units or automatic mode:</p>
<p><code><br />
function file_size($file,$unit='auto') {<br />
	$retval = false;<br />
	if (file($file)) {<br />
		$filesize = filesize($file);<br />
		if ($unit == 'GB' || $unit == 'auto' &amp;&amp; $filesize &gt;= pow(1024,3)) {<br />
			$retval = round(($filesize / pow(1024,3)),2) . 'GB';<br />
		} elseif ($unit = 'MB' || $unit == 'auto' &amp;&amp; $filesize &gt;= pow(1024,2)) {<br />
			$retval = round(($filesize / pow(1024,2)),2) . 'MB';<br />
		} elseif ($unit = 'KB' || $unit == 'auto' &amp;&amp; $filesize &gt;= 1024) {<br />
			$retval = round(($filesize / 1024),2) . 'KB';<br />
		} else {<br />
			$retval = $filesize . 'Bytes';<br />
		}<br />
	}<br />
	return $retval;<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: telo</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-5795</link>
		<dc:creator>telo</dc:creator>
		<pubDate>Sun, 27 Feb 2011 03:33:19 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-5795</guid>
		<description>thanks for the code. really usefull</description>
		<content:encoded><![CDATA[<p>thanks for the code. really usefull</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Abeon</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-4458</link>
		<dc:creator>Abeon</dc:creator>
		<pubDate>Mon, 05 Apr 2010 13:01:12 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-4458</guid>
		<description>A very simple and effective solution, thanks for sharing it!</description>
		<content:encoded><![CDATA[<p>A very simple and effective solution, thanks for sharing it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: laptop satÄ±ÅŸ</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-2252</link>
		<dc:creator>laptop satÄ±ÅŸ</dc:creator>
		<pubDate>Mon, 20 Oct 2008 12:19:28 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-2252</guid>
		<description>Ä± like this blog . . .</description>
		<content:encoded><![CDATA[<p>Ä± like this blog . . .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-1397</link>
		<dc:creator>john</dc:creator>
		<pubDate>Sun, 02 Mar 2008 13:56:14 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-1397</guid>
		<description>Glad it could help. Thanks for the correction - it&#039;s been fixed.</description>
		<content:encoded><![CDATA[<p>Glad it could help. Thanks for the correction &#8211; it&#8217;s been fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://www.linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/comment-page-1/#comment-1394</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Sun, 02 Mar 2008 02:34:34 +0000</pubDate>
		<guid isPermaLink="false">http://linein.org/blog/2007/04/25/php-file-last-modified-and-filesize-bytes-to-kbmb/#comment-1394</guid>
		<description>Exactly what I was looking for. Just change the comment for the second line to &quot;// bytes to MB&quot; instead of KB. It&#039;s a little misleading.</description>
		<content:encoded><![CDATA[<p>Exactly what I was looking for. Just change the comment for the second line to &#8220;// bytes to MB&#8221; instead of KB. It&#8217;s a little misleading.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic
Database Caching 1/23 queries in 0.064 seconds using disk: basic

Served from: www.linein.org @ 2012-02-09 08:57:22 -->
