【问题标题】:Jcrop and IE9 Image File is UndefinedJcrop 和 IE9 图像文件未定义
【发布时间】:2014-03-28 22:19:54
【问题描述】:

由于某种原因,IE9 决定在 Jcrop 和从要上传的文件中获取数据时遇到问题。这一行:

var oFile = $('#image_file')[0].files[0];

我收到:Unable to get properly '0' of undefined or null reference

归根结底,我需要能够访问文件的属性...而 IE9 似乎无法通过请求 [0].files[0] 来运行

【问题讨论】:

    标签: javascript jquery internet-explorer internet-explorer-9 jcrop


    【解决方案1】:

    IE9没有这样的属性,input type="file"files属性是在IE10中引入的。

    【讨论】:

    • 好的,这肯定会有所帮助...但是解决方法是什么?
    • Jcrop 支持 IE6+ ...我不认为这是 Jcrops 的错,但我在上面评论的那一行:var oFile = $('#image_file')[0].files[0];
    • "This page was last modified on 13 August 2008, at 19:41" --> Jcrop 不一定支持 IE9 :)。
    • 底线是我需要一个文件对象...所以我可以提取sizetype 等。然后像oReader.readAsDataURL(oFile); 一样传递该对象以继续处理请求。
    【解决方案2】:

    我不熟悉 Jcrop,但对于 IE9-,访问 id 为 image_file 的 div 时出现问题

    我使用此代码将图像加载到变量中:

     $('#image_file').change(function () {
                        var oFile = this.files[0];
              //...
        });
    

    【讨论】:

    • 这是 IE9 中的问题所在:var oFile = $('#image_file')[0].files[0];
    猜你喜欢
    • 1970-01-01
    • 2011-09-06
    • 2011-03-01
    • 2013-10-29
    • 2016-04-10
    • 2020-03-09
    • 1970-01-01
    • 1970-01-01
    • 2011-12-11
    相关资源
    最近更新 更多