Search code examples
javascriptiframeactivexfilesystemobjectinput-type-file

How to open, modify and save a file with javascript and ActiveX?


I tried different methods to open and show a file on client without to send the file to a server.

Opening: I tried to access the file with javascript from a <input type=file>, but the security restriction seems to not allow that. I tried also <iframe src=file://local.path> with the same problem. Last i tried with new ActiveXObject('Scripting.FileSystemObject');, but I get always an error that automationserver could not create the Object.

For saving I tried to use execCommand('SaveAs',true) from TextRange and DocumentFragment. From DocumentFragment I'm able to save a file but it contains only <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">. From TextRange is no save dialog shown.

What could I do?


Solution

  • From a web site, you cannot do any of this unless you use a signed script

    From local file system, IE can use the filesystem object from an HTA