HTML5Labs is where Microsoft prototypes early and unstable specifications from web standards bodies such as W3C. Sharing these prototypes helps us have informed discussions with developer communities, and enables us to provide better feedback on draft specifications based on this implementation experience. To find out more about HTML5Labs, read the blog by Dean Hachamovitch, Corporate Vice President for Internet Explorer, and the blog by Jean Paoli, President, Microsoft Open Technologies, Inc.

Important Note: This feature is now available in the IE10 Platform Preview that was released at Microsoft's recent Build conference with the Developer Preview of Windows 8. You might notice some differences between the IE10 Platform Preview implementation. We recommend using the IE10 Platform Preview instead of this prototype as we don't plan any future updates to this prototype.

 

FileAPI is a W3C draft Web specification for representing file objects in web applications, as well as programmatically selecting them and accessing their data. The FileAPI is currently being standardized by the W3C Web Applications Working Group.

Today May 5th 2011 we updated the FileAPI prototype to include a fix an issue in the File.Slice method as reported in the latest version of the spec.

By using FileAPI web developers can access local file on the client machine in a secure way without the need of extensions or plugins.

The following example shows how the FileAPI can be used to let the user to select some files and diplays properties such as size, date modified and so on:


1: // GetFileSelector is not part of the FileAPI spec, it is used only

2: // to get a reference of the FileAPI ActiveX prototype

3: var fileSelector = GetFileSelector();

4:  

5: // Show dialog

6: var iFileList = fileSelector.OpenFileDialog();

7: fileSelector.close();

8:  

9: var i = 0;

10: while (i < iFileList.length) {

11:     var iFileObject = iFileList[i];

12:     if (iFileObject) {

13:         alert("File Name: " + iFileObject.name + "; Last modified date: "

14:              + iFileObject.lastModifiedDate + "; File size: " + iFileObject.size);

15:     }

16:     i++;

17: }