Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
How can I get the size of a file using JavaScript (preferably using MooTools 1.2)?
如果您正在谈论提供给<input>“文件”类型标记的文件的大小,或者您的 Web 应用程序恰好知道其路径的文件,那么除了在某些非常特殊的情况下(例如加载的页面),您不能来自“file://”URL)。
<input>
如何使用 JavaScript(最好使用 MooTools 1.2)获取文件的大小?
本地还是远程?
如果它是远程的,我会做一个 HTTP HEAD 请求并检查 Content-Length 字段。