hello,
I'm interested on the solution because i tried to do the same. In my
application, the user can modified a file which is in the local store
and then send it back to the server with a button "synchronize".
I had 2 problems:
- how to access to the file path?
- how to send it back to the server automatically?
my solutions are:
- how to access to the file path?
I used a signed java applet which can find the local path of a file,
the problem is that all file path are different according to the os
and the navigator. I would prefer to have directly a gears method like
"var filepath = store.getPath(string URL)" or maybe it can be find on
the gears source code.
- how to send it back to the server automatically?
For the moment I managed to do it, filling an input file
automatically. Problem: it just works on firefox and users have to
change a firefox config:"signed.applets.codebase_principal_support" to
true.
If you are interested, here my code:
---------------------------
html file
---------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script archive="test1.jar" type="text/javascript" src="test1.js" ></
script>
</head>
<body>
<form>
Text: <input type="text" id="mytext" name="mytext" size="40">
<br>
File: <input type="file" id="myfile" name="datafile" size="40"><br>
<input type="button" id="ajax" value="read2inputFile"
onclick="fillInputFile('/home/loic/Bureau/json2.js');">
</form>
<div id="sizespan"></div>
<hr>
<div id="myspan"></div>
</body>
</html>
-------------------------------
javascript file
-------------------------------
var filename;
var mytext;
function fillInputFile(filepath){
try {
netscape.security.PrivilegeManager.enablePrivilege
("UniversalXPConnect");
//netscape.security.PrivilegeManager.enablePrivilege
('UniversalFileRead');
}
catch(e){
alert("Permission to read file was denied.");
}
var fileIn = document.getElementById("myfile");
var aFile = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
aFile.initWithPath(filepath);
if (aFile.exists()) {
alert("dataObj filename is " + aFile.path);
fileIn.value = aFile.path;
}
}
I know these solutions are not best ones but It can help.
Loïc
On Apr 22, 7:15 am, skunkwerk <[email protected]> wrote:
> i'm using gears to write a local application, and i need to be able to
> get the full path of a file (such as an image) so i can insert it into
> my rich text editor. thanks to firefox's wonderful new security
> policy, i can no longer use a simple <input type='file'> to retrieve
> that value - all i get is the file name. i then tried the openFiles
> function in the desktop api of gears, but lo and behold - again, all i
> get is the filename - no path!
>
> 1) is gears just wrapping the browser's existing file input (in which
> case, it's not gears limiting access to the file path)?
> 2) if not, where in the source code for gears should i look to change
> this restriction?
>
> thanks,
> imran