Koding
Oct2

Mendapatkan ukuran file di php

Ktzagcplugin free agcplugin
Iklan

Fungsi mendapatkan ukuran file di php

/*
 * @param string $file File name or path to a file
 * @param int $precision Digits to display after decimal
 * @return string|bool Size (B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB) or boolean
 */

function ktz_getfilesize($file, $precision = 2) {
	static $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB');

	if (is_file($file)) {
		if (!realpath($file)) $file = $_SERVER['DOCUMENT_ROOT'] . $file;
		$fileSize = filesize($file);

		// hardcoded maximum number of units @ 9 for minor speed increase
		$power = max(floor(log($fileSize, 1024)), 8);
		return round($fileSize / pow(1024, $power), $precision) . $units[$power];
	}
	return false;
}
Tags:
Iklan
Rate this article!

Author: 

Freelance designer, tidak terpaku sama yang namanya waktu, hobby mengunjungi localhost setelah itu baru OL. Suka pusing kalau melihat kode kode yang aneh. :| Jangan lupa add ane di link social newtwork dibawah.

author

Related Posts "Mendapatkan ukuran file di php"

Leave a reply "Mendapatkan ukuran file di php"

Captcha: * Time limit is exhausted. Please reload CAPTCHA.