Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在IE中获得更改时的文件输入_Javascript_Jquery_Html_Internet Explorer - Fatal编程技术网

Javascript 如何在IE中获得更改时的文件输入

Javascript 如何在IE中获得更改时的文件输入,javascript,jquery,html,internet-explorer,Javascript,Jquery,Html,Internet Explorer,我需要加载一个文件以进行输入。 此代码适用于chrome、opera和firefox,但不适用于IE: $("input:file").change(function () { // Get a reference to the fileList var files = !!this.files ? this.files : []; // If no files were selected, or no FileReader support, return if ( !files

我需要加载一个文件以进行输入。 此代码适用于chrome、opera和firefox,但不适用于IE:

$("input:file").change(function ()
{
  // Get a reference to the fileList
  var files = !!this.files ? this.files : [];
  // If no files were selected, or no FileReader support, return
  if ( !files.length || !window.FileReader ) return;
  // Only proceed if the selected file is an text
  if ( /^text/.test( files[0].type ) ) 
  {
    var reader = new FileReader();
    reader.readAsText( files[0] );
    reader.onloadend = function()
    {
      restoreCSS(this.result);
    }
  }
}

在IE中
!!此.files
返回false。感谢您的提前通知。

您正在使用哪个版本的IE


正如@apsillers所评论的那样,存在着一些问题。我相信它们都需要某种插件(Flash/Silverlight),就像以前的
FileReader
API一样,JavaScript无法访问文件系统。

@Andrew:谢谢你的解释。这个问题已经结束。