getFileSize 获得文件大小
发布时间:2020-12-17 08:00:01 所属栏目:百科 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 % ' Copyright (c) 2009,reusablecode.blogspot.com; some rights reserved. ' ' This work is licensed under the Creative Commons Attribution Lic
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 <% ' Copyright (c) 2009,reusablecode.blogspot.com; some rights reserved. ' ' This work is licensed under the Creative Commons Attribution License. To view ' send a letter to Creative Commons,559 Nathan Abbott Way,Stanford,California ' 94305,USA. ' Retrieve the file size of a given file. function getFileSize(someFile) dim fs dim file set fs = Server.CreateObject("Scripting.FileSystemObject") set file = fs.GetFile(Server.MapPath(someFile)) getFileSize = FormatFileSize(file.size) set file = nothing set fs = nothing end function ' Format a file size in the most practical units. ' Input: size in bytes function FormatFileSize(size) dim units dim factor units = Array("B","kB","MB","GB","TB","PB","EB","ZB","YB") factor = log(size) 7 FormatFileSize = Round(size / (1024 ^ factor),2) & units(factor) end function %> 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |