开发者

What's the difference in these ways of determining uploaded file size in PHP?

I came across this piece of code where programmer determines uploaded file size like this开发者_如何学Go:

$file_size = @filesize($_FILES[$upload_name]["tmp_name"]);

AFAIK one can simply do:

$_FILES[$upload_name]["size"];

Are there reasons to use filesize() function over reading file size from $_FILES array?


$_FILES[$upload_name]["size"]

This is populated for you by PHP after receiving the uploaded file.

$file_size = @filesize($_FILES[$upload_name]["tmp_name"]);

This is a wasteful method that goes out and gets the file size from the drive, even though it's already populated inside $_FILES[$upload_name]["size"].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜