The Use of Flash and the Open XML SDK for JavaScript
This functionality is deprecated. I recommend using HTML5 only.
Return to the
Open XML SDK for JavaScript
Developer CenterFor some time, the ability to load files from the local file system into local JavaScript variables, and to save files from local JavaScript variables to the local file system has been deemed to be a security risk. However, with the development of more and more powerful Web applications that use a lot of client-side JavaScript, the need to do this has increased. At the same time, security experts have decided, to a large extent, that if we place
certain limitations on loading and save files from/to the local file system, it is not a security risk. The limitations are:
- The only capability of JavaScript / HTML5 is to put up a user interface control and enable the end-user to click on it. Without a specific user action, JavaScript can’t load or save a file.
- When the user loads a file, the only information that the user retrieves is the data in the file, and the name of the file (but not the path or location of the file).
- When the user saves a file, your JavaScript program can suggest a default filename, however, the JavaScript code can’t access the actual details of where the end-user saved the file.
This is the direction being taken by the W3C committees. The FileReader interface enables opening files, and the FileWriter API enables saving to the local file system. However, these are works in progress. Support is spotty.
In the mean-time, there is a work-around. From Flash 10 onwards, it has been possible in ActionScript to read and write to the local file system (with the same limitations as listed above). Further, there is interop between ActionScript and JavaScript so that it is easy to pass data both directions. This means that it is possible to write a small Flash module that does the actual loading and saving of files, and then use those Flash modules from JavaScript.
You can find out more about this approach in the screen-cast Working with Open XML Documents using JavaScript.