Saving local files in javascript under Opera
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Saving local files in javascript under Opera

From: André Wagner <andre.nho@gmail.com>
Date: Mon Apr 24 2006 - 19:10:32 CEST

Hello,

I'm writing a HTML/javascript application who will run locally. I want
to save to a local file.

If I were using IE, I would do this way:

  var fso = new ActiveXObject("Scripting.FileSystemObject");
  var file = fso.OpenTextFile(filePath,2,-1,0);
  file.Write(content);
  file.Close();

If I were using Mozilla, I would do like this:

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  var file =
Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
  file.initWithPath(filePath);
  if (!file.exists()) file.create(0, 0664);
  var out =
Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
   out.init(file, 0x20 | 0x02, 00004,null);
  out.write(content, content.length);
  out.flush();
  out.close();

But I couldn't figure out how to do it using Opera. Does anyone has any
idea?

Thank you in advance,

André
Received on Mon May 1 05:18:43 2006