如何找到文件的下载大小?

How to find the download size of a file?

我遇到了一个问题,我的 website.I 应用了下载数据限制检查,用户可以选择下载文件 his/her profile.My 问题是:

How to find the download size of a file? So, I have applied the appropriate limit checks.

您可以使用 PHP 的 filesize() 函数:

$size = filesize('/path/to/file');

这将 return 文件的大小(以字节为单位)。

试试这个..

Returns 文件大小(以字节为单位),如果出现错误,则为 FALSE(并生成级别 E_WARNING 的错误)。

注意: 因为 PHP 的整数类型是有符号的,而且许多平台使用 32 位整数,一些文件系统函数可能 return 对文件的意外结果大于 2GB。

<?php

// outputs e.g.  somefile.txt: 1024 bytes

$filename = 'somefile.txt';
echo $filename . ': ' . filesize($filename) . ' bytes';

?>

http://www.php.net/manual/en/function.filesize.php