Kermit: input file - den kompletten Pfad übertragen

Beitrag lesen

Danke für die Hilfe. Geholfen hat der Link von ChrisB. Darauf bin ich auf folgenden Hinweis gestoßen:
https://bugzilla.mozilla.org/show_bug.cgi?id=143220

Anbei meine Lösung für IE und Firefox ... gewünschter Datei-Pfad ist anschließend im doc_file zu finden.

<script type="text/javascript">
function readFile(fileBrowser) {
if (navigator.userAgent.indexOf("MSIE")!=-1) {
readFileIE(fileBrowser);
} else if (navigator.userAgent.indexOf("Firefox")!=-1 || navigator.userAgent.indexOf("Mozilla")!=-1) {
readFileFirefox(fileBrowser);
} else {
alert("Not IE or Firefox (userAgent=" + navigator.userAgent + ")");
}
}

function readFileFirefox(fileBrowser) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
    alert('Unable to access local files due to browser security settings. To overcome this, follow these steps: (1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again.');
    return;
}

var fileName=fileBrowser.value;  
//alert("fileName:"+fileName);  
document.getElementById("doc\_file").value=fileName;  
//alert("document.getElementById(doc\_file).value:"+document.getElementById("doc\_file").value);  

}

function readFileIE(fileBrowser) {
  var data;
  try {
var fso = new ActiveXObject("Scripting.FileSystemObject");

	var fileName=fso.GetAbsolutePathName(fileBrowser.value);  
	//alert("fileName:"+fileName);  
	document.getElementById("doc\_file").value=fileName;  
	//alert("document.getElementById(doc\_file).value:"+document.getElementById("doc\_file").value);  

} catch(e) {
if (e.number == -2146827859) {
    // This is what we get if the browser's security settings forbid
    // the use of the FileSystemObject ActiveX control...
    alert('Unable to access local files due to browser security settings. To overcome this, go to Tools->Internet Options->Security->Custom Level. Find the setting for "Initialize and script ActiveX controls not marked as safe" and change it to "Enable" or "Prompt"');
} else if (e.number == -2146828218) {
    // This is what we get if the browser can't access the file
    // because of file permissions...
    alert("Unable to access local file '" + FLFileName + "' because of file permissions. Make sure the file and/or parent directories are readable.");
} else {
   throw e;
  }
  }
}
</script>

<form>
...
<INPUT TYPE='HIDDEN' NAME='doc_file' ID='doc_file' value=''>
<B>1. Input DOC-File: </B>
<INPUT TYPE='FILE' SIZE=48 NAME='doc_file_name' ID='doc_file_name' onchange='readFile(this)'>

...
</form>