0

我正在做某事并且问题得到了回答,但我需要它的不同用途。我有一个关于它如何工作的 jsFiddle。 http://jsfiddle.net/TbZzH/4/

这很好,花花公子,但是当我在我的代码中这样做时,它会告诉我 data.files[0] 不起作用,并且据说是未定义的。它也不识别 FileReader() 对象。

我的代码如下,以 jsFiddle 为例。

$(function(){
  $("input[type='file'].attribute").on("change", function () { updateDesigner(this); });
});
function updateDesigner(input){
  var t = input;
  if ($(input).attr("type") == 'file'){
    try{
      var data = $(t)[0];
      var file = data.files[0];   //<------   FAILS HERE.  .files is an undefined attr.
      var reader = new FileReader();   //<--- working around it, doesnt understand this object as well
      reader.onload = function (e) {
          value = e.target.result;
      }
      reader.readAsDataURL(file);
    }catch(errrrr){
      alert("error putting image into image tag: "+errrrr.toString());
    }
  }
  srcFunction(value); //takes the value and applied it to the src attr of the image tag.
}

我想将数据转化为价值,一切都会顺利进行,但我不确定发生了什么。

4

1 回答 1

0

While IE works with some examples, The issues here seem to be related to the websites "trust" and "secureness"

to get a static image to appear on the computer screen, i need to make it a trusted site as well as having the rerouted to https

于 2012-06-27T12:57:16.550 回答