• 08-11-2007, 23:15:54
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Merhaba arkadaslar,

    Bir klasörün icindeki dosylarin toplam boyutunu MB olarak nasil gösteririm ?

    simdiden tesekkürler
  • 09-11-2007, 02:06:01
    #2
    sizeof() fonksiyonuydu sanırım kontrol etmedim
  • 09-11-2007, 12:05:41
    #3
    Daha aciklayici yazarsaniz daha cok yardimci olmus olursunuz.
    Ilginiz icin tesekkür ederim.
  • 09-11-2007, 16:22:20
    #4
    Üyeliği durduruldu
    $dosya = "ahmetpasha.txt";
    $boyut = filesize($dosya);
    echo "$dosya adlı dosyanın boyutu $boyut byte.";
    bu şekilde bi deneyelim ?
  • 09-11-2007, 16:37:14
    #5
    Ilgin icin tesekkür ederim fakat tam istedigim bu degil,
    bir klasörün icindeki bütün dosyalarin boyutu
    senin verdigin 1 dosyanin boyutu ?
  • 09-11-2007, 16:43:50
    #6
    directory i read edip, while a baglayıp tek tek size ları + ederek bulabilirsin

    $path = "/home/haymac/www";
    $dh = opendir($path);
    $i=0;
    clearstatcache();
    while (($file = readdir($dh)) !== false) {
    if($file != "." && $file != "..") {
    $i = $i+filesize("$path/$file");
    }
    }
    closedir($dh);
    echo "Toplam boyut $i";
  • 09-11-2007, 16:57:01
    #7
    Tesekkür ederim
    kücük bisey kaldi. ekranda Byte olarak yaziyor Mbyte olarak yazdirmak icin 2048'e nasil bölecegim
  • 09-11-2007, 17:02:58
    #8
    function size_readable($size, $unit = null, $retstring = null, $si = true)
    {
    // Units
    if ($si === true) {
    $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB');
    $mod = 1000;
    } else {
    $sizes = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
    $mod = 1024;
    }
    $ii = count($sizes) - 1;

    // Max unit
    $unit = array_search((string) $unit, $sizes);
    if ($unit === null || $unit === false) {
    $unit = $ii;
    }

    // Return string
    if ($retstring === null) {
    $retstring = '%01.2f %s';
    }

    // Loop
    $i = 0;
    while ($unit != $i && $size >= 1024 && $i < $ii) {
    $size /= $mod;
    $i++;
    }

    return sprintf($retstring, $size, $sizes[$i]);
    }

    $path = "/home/haymac/www";
    $dh = opendir($path);
    $i=0;
    clearstatcache();
    while (($file = readdir($dh)) !== false) {
    if($file != "." && $file != "..") {
    $i = $i+filesize("$path/$file");
    }
    }
    closedir($dh);
    echo "Toplam boyut ".size_readable($i)."";
  • 09-11-2007, 17:09:03
    #9
    Cok tesekkür ederim