|
|
|
ขอความอนุเคราะห์ โค้ด php เรื่อง การเช็คขนาด folder |
|
|
|
|
|
|
|
Code (PHP)
<?php
function foldersize( $path )
{
$size = 0;
if( $dir = @opendir( $path )) {
while(($file = readdir($dir)) !== false ) {
if( is_dir( "$path/$file" ) && $file != '.' && $file != '..' ) {
$size += foldersize( "$path/$file" );
}
if( is_file( "$path/$file" )) {
$size += filesize( "$path/$file" );
}
}
closedir($dir);
}
return $size;
}
$sizes['files'] = 0;
if( $dir = @opendir( '.' )) {
while(($file = readdir($dir)) !== false ) {
if( is_dir( "$file" ) && $file != '.' && $file != '..' ) {
$sizes[$file] = foldersize( "$file" );
}
if( is_file( "$file" )) {
$sizes['files'] += filesize( "$file" );
}
}
closedir($dir);
}
$totsize = 0;
foreach( $sizes as $fsize ) {
$totsize += $fsize;
}
echo "<table>";
foreach( $sizes as $key => $size ) {
$perc = 100 * $size / $totsize;
$width = 4 * $perc;
$percstr = number_format( $perc, 1 ) . '%';
$sizestr = number_format( $size );
printf( '<tr><td>%s</td><td align="right">%s</td><td><img src="red_dot.gif" width="%s" ' .
'height="10" border="0" alt="%s"> %s</td>', $key, $sizestr, $width, $percstr,$percstr );
}
echo "</table>";
?>
Go to : [url=https://www.thaicreate.com/php/forum/025442.html]get folder size - พี่ๆ มี code ตรวจสอบขนาดของ โฟรเดอ แบบตามพาทเปล่าครับ เช่น c:\windows[/url]
|
|
|
|
|
Date :
2012-01-17 06:25:02 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ฟ้ง
|
|
|
|
|
Date :
2012-02-29 10:39:43 |
By :
ฟ้ง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|