How to Enable JavaScript file API in IE8

25,670

Solution 1

You can't install anything special to add support for File API in IE8. What you can do is use a polyfill in order to implement this functionality in browsers that don't natively support it. Take a look at this list of HTML5 Cross Browser Polyfills (you should find something suitable for you in File API / Drag and Drop section).

Solution 2

This works for me in pre IE10, i use https://github.com/eligrey/FileSaver.js for every other browser, note though this works it's not perfect, because it's IE and well you know what I mean

Hope this helps

/**
 * saves File, pops up a built in javascript file as a download
 * @param {String} filename, eg doc.csv
 * @param {String} filecontent eg "this","is","csv"
 * @param {String} mimetype eg "text/plain"
 */
function saveAs (filename, filecontent, mimetype) {
    var w = window.open();
    var doc = w.document;
    doc.open( mimetype,'replace');
    doc.charset = "utf-8";
    doc.write(filecontent);
    doc.close();
    doc.execCommand("SaveAs", null, filename);
}

Solution 3

After some researches i have got there is no way to Enable file API in IE8 but, i got some thing that want to share it with you .....
Not directly, HTML 5 is not supported by IE8. There is addons for Canvas, and also there is Google Chrome Frame, a plugin to add HTML 5 to IE older than 9.
As i understood , Google Chrome Frame is perfect way to use HTML5.
It increases IE speed 10 times and also it's usage is very easy and i describe it for you all members...
Google Chrome Frame

A plugin for Internet Explorer that add to the Microsoft's browser, a full HTML 5 support and the JavaScript compiler of Chrome! A stable version was released on September 22, 2010 and a lot of sites have added the code in their pages.

This plugin will work on Internet Explorer 6, 7 and further versions. Google wants to break a barrier that prevents the Web to evolve: the most common browser and its lack of compatibility with the new standards.

When it is recognized, Internet Explorer will run under WebKit, the rendering engine of Chrome and Safari, and the it will use the ultra-fast JavaScript compiler in replacement if the IE interpreter.

The advantage of this plugin is great for the compatibility of web applications and will become even more useful with WebGL integrated in Webkit, which let us have applications in 3D on the browser: a very different Web! WebGL is also supported by Firefox since the version 3.7.

Since May 2011, the plugin can be installed without administrator rights, so on older version of IE which are incorporated into a server and can not be updated.

A tag in the code of a Web page will display a message prompting the user to download the plugin. Once it is installed, IE run as Chrome and will support HTML 5.

Features of Frame

The off-line mode. The and tags. Microsoft also plans to implement them in IE. Canvas. WebGL. CSS 3. JavaScript compiler. Compatibility at Acid 3 level. See the vidéo.

Reaction from Microsoft

We were expecting that Microsoft has not appreciated really this initiative that promotes HTML 5 to the detriment of their own solution, Silverlight. The firm highlights a security problem:

Given the security issues with plug-ins in general and Google Chrome in particular, Google Chrome Frame running as a plug-in has doubled the attack area for malware and malicious scripts.

**

Chrome Frame. Automatic install. -> http://www.google.com/chromeframe/?quickenable=true
Google Chrome Frame code. -> https://developers.google.com/chrome/chrome-frame/
Chrome Frame: Developer Guide. -> http://www.chromium.org/developers/how-tos/chrome-frame-getting-started

**

Share:
25,670
saeed
Author by

saeed

About me I'm an independent software engineer with a particular interest in C#,Java,C++ and several other languages. I've been doing this professionally for over 5 years. I am from generation who starts programming with pascal and Turbo c++ I studied most of programming issues on a self-study project. Send email to saeedsoleimanifar@ google's mail site if you want to get in touch.

Updated on February 25, 2020

Comments

  • saeed
    saeed about 4 years

    I have developed a web application in asp.net, there is a page in this project which user should choose a file in picture format (jpeg, jpg, bmp,...) and I want to preview image in the page but I don't want to post file to server I want to handle it in client i have done it with java scripts functions via file API but it only works in IE9 but most of the costumers use IE8 the reason is that IE8 doesn't support file API is there any way to make IE8 upgrade or some patches in code behind I mean that check if the browser is IE and not support file API call a function which upgrades IE8 to IE9 automatically.

    I don't want to ask user to do it in message I want to do it programmatically!!
    even if it is possible to install a special patch that is required for file API because customers thought it is a bug in my application and their computer knowledge is low what am I supposed to do with this?
    I also use Async File Upload Ajax Control But it post the file to server any way with ajax solution and HTTP handler but java scripts do it all in client browser!!!

    following script checks the browser supports API or not

    <script>
    if (window.File && window.FileReader && window.FileList && window.Blob) 
      document.write("<b>File API supported.</b>");
    else
      document.write('<i>File API not supported by this browser.</i>');
    </script>   
    

    following scripts do the read and Load Image

    function readfile(e1)
    {
      var filename = e1.target.files[0]; 
      var fr = new FileReader();
       fr.onload = readerHandler;  
      fr.readAsText(filename); 
    } 
    

    HTML code:

    <input type="file" id="getimage">
    
    <fieldset><legend>Your image here</legend>
        <div  id="imgstore"></div>
    </fieldset> 
    

    JavaScript code:

    <script>
    function imageHandler(e2) 
    { 
      var store = document.getElementById('imgstore');
      store.innerHTML='<img src="' + e2.target.result +'">';
    }
    
    function loadimage(e1)
    {
      var filename = e1.target.files[0]; 
      var fr = new FileReader();
      fr.onload = imageHandler;  
      fr.readAsDataURL(filename); 
    }
    
    window.onload=function()
    {
      var x = document.getElementById("filebrowsed");
      x.addEventListener('change', readfile, false);
      var y = document.getElementById("getimage");
      y.addEventListener('change', loadimage, false);
    }
    </script>