跨浏览器在客户端检查文件大小,然后将其上传到服务器? [英] Cross-browser checking on file size at client side before uploading it to the server?
问题描述
客户端验证对于提高可用性非常重要。
是否有任何跨浏览器方法来验证文件大小,然后将其上传到服务器。我使用asp.net文件上传控件。
我发现一些第三方控件可以检查:
http://ajaxuploader.com/Demo/simple-upload.aspx p>
和
http://demo.essentialobjects.com/Default.aspx?path=AJAXU
但是如何?
以前,在文件发送到服务器之前确定文件大小的唯一方法是使用thick than javascript侧插件/附加组件。这些必须安装在客户端系统上。例如。使用SWFUpload,Java applet,ActiveX控件。
现在,您可以使用HTML5 File API,例如:
var size = document.getElementById('myfile')。files [0] .size;
Client side validation is important to improve usability.
Is there any cross-browser way to validate the file size before uploading it to the server. I am using asp.net file upload control.
I found some third-party controls do that check:
http://ajaxuploader.com/Demo/simple-upload.aspx
and
http://demo.essentialobjects.com/Default.aspx?path=AJAXU
but How?
Previously, the only way to determine the filesize before the file was sent over to the server was to have 'thicker than javascript' client-side plugins/add-ons. These would have to be installed on the client system. E.g. using SWFUpload, Java applets, ActiveX controls.
Now, you can use the HTML5 File API, i.e.:
var size = document.getElementById('myfile').files[0].size;
这篇关于跨浏览器在客户端检查文件大小,然后将其上传到服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!