2013-01-31 139 views
-1

我有一个在Chrome和Firefox工程的下一个代码,但是IE发送“未定义”的消息。输入文件的onChange IE

<input type="file" name="image" onchange="inputFileChange(this);"/> 

function inputFileChange(el) { 
    console.log($(el).context.files); 
} 

这是firefox和chrome中console.log的结果。

FileList 
    0: File 
     lastModifiedDate: Thu Dec 20 2012 19:01:23 GMT-0600 (Hora estándar central (México)) 
     name: "izq02_a.jpg" 
     size: 69767 
     type: "image/jpeg" 

...这是导致IE

REGISTER: undefined 

我需要的图像文件大小上传之前,任何想法?

+0

其上的代码的jQuery? – Toping

回答

1

IE10具有与文件API部分支持,但早期版本也没有。

Here's an old question on the topic.人都使用闪存解决方案作为一种解决方法(以及和尽可能的唯一途径文件API出现之前)。

您可以使用CanIUse检查对各种事物浏览器的支持,以及HTML5Please

+0

似乎我可以使用Scripting.FileSystemObject来完成它,但它依赖于IE安全配置。 – a77icu5

+1

F ** k!伟大的链接@Pointy CandIUse真的有用 – a77icu5

+0

是这两个网站都是不错的 - 答案可有时令人沮丧,虽然:-) – Pointy