PHP能 读取本地文件名
如何读取本地文件
<?php
$filename = '/data/webroot/usercode/resource/test.txt';
//取得文件的大小并输出
$size = filesize($filename);
function getsize($size, $format = 'kb') {
$p = 0;
if ($format == 'kb') {
$p = 1;
} elseif ($format == 'mb') {
$p = 2;
} elseif ($format == 'gb') {
$p = 3;
}
$size /= pow(1024, $p);
return number_format($size, 3);
}
$size = getsize($size, 'kb'); //进行单位转换
echo $size.'kb';
举报