【问题标题】:addMethod error on IE9IE9上的addMethod错误
【发布时间】:2012-07-25 00:19:41
【问题描述】:

我有这个脚本可以在您上传文件时验证文件大小:

$.validator.addMethod('filesize', function(value, element, param) {
    // param = size (en bytes) 
    // element = element to validate (<input>)
    // value = value of the element (file name)
    return this.optional(element) || (element.files[0].size <= param) 
});

而且我只在 IE9 中不断收到此错误:

SCRIPT5007: Unable to get value of the property '0': object is null or undefined

IE9 Debug 说错误在这一行:

return this.optional(element) || (element.files[0].size <= param)

【问题讨论】:

    标签: javascript jquery html internet-explorer-9


    【解决方案1】:

    是的,IE9 不支持文件 API。您需要在服务器端执行此操作或使用插件。

    【讨论】:

    • 知道我可以使用什么插件使它在所有浏览器中都能正常工作吗?
    • 试试Plupload,是使用最广泛的。 WordPress 使用这个插件。
    猜你喜欢
    • 1970-01-01
    • 2018-07-12
    • 1970-01-01
    • 2012-06-14
    • 2015-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-12
    相关资源
    最近更新 更多