简体   繁体   English

上传时检查文件大小

[英]file size check at the time of upload

I wan to check the size of file at the time of upload in javascript (its an image file so if possible want to check in kb or bytes or in px) 我想在javascript中上传时检查文件的大小(它是图像文件,因此,如果可能的话,请检查kb或字节或px)

Is there any way i can do it. 有什么办法我可以做到的。

Thanks in advance! 提前致谢!

<input type="file" name="ssimgfile2" id="ssimgfile2" />

JavaScript natively cannot find any information about a file other than the name. JavaScript本身无法找到有关文件名称的任何信息。 I know with Windows you can create a File System Object by defining a new ActiveX Object like so: 我知道在Windows中,您可以通过定义新的ActiveX对象来创建文件系统对象,如下所示:

var myFSO = new ActiveXObject("Scripting.FileSystemObject");

I would advise using a Server Side scripting language like ASP, ColdFusion, or PHP depending on what type of web server you have. 我建议您使用服务器端脚本语言,例如ASP,ColdFusion或PHP,具体取决于您拥有的Web服务器类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM