Kermit: input file - den kompletten Pfad übertragen

Hi,

in den neuen Browser wir aus Datenschutzgründen in input file nicht mehr den kompletten Pfad übertragen nur dir Dateiname.
Wie kann ich trotzdem an den lokalen Pfad dran kommen um mittels Javascript oder anders zu übertragen.

Es ist eine lokale Applikation die genau diesen Pfad brauch um an die Datei dran zu kommen.

Danke und Gruß
Kermit

  1. Gar nicht. Zumindest nicht rein clientseitig mit JavaScript oder ähnlichen Techniken. Es gibt zwei Möglichkeiten, um den Pfad trotzdem zu ermitteln:

    • implementiere den Datei-Auswahl-Dialog serverseitig bzw. mit Asynchronen JS-Requests
    • baue ein Flash, dass Dir diese Informationen liefert.

    Gruß, LX

    --
    RFC 1925, Satz 6a: Es ist immer möglich, einen weiteren Umweg einzufügen.
    RFC 1925, Satz 11a: Siehe Regel 6a
    1. Hallo,

      • baue ein Flash, dass Dir diese Informationen liefert.

      Meinst du mittels FileReference-Objekt? Dieses liefert auch nicht den Pfad der ausgewählten Datei.

      Grüße Basti

      1. Stimmt, Du hast Recht. Streichen wir also die 2. Alternative.

        Gruß, LX

        --
        RFC 1925, Satz 6a: Es ist immer möglich, einen weiteren Umweg einzufügen.
        RFC 1925, Satz 11a: Siehe Regel 6a
        1. 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>

  2. Hi,

    in den neuen Browser wir aus Datenschutzgründen in input file nicht mehr den kompletten Pfad übertragen nur dir Dateiname.
    Wie kann ich trotzdem an den lokalen Pfad dran kommen um mittels Javascript oder anders zu übertragen.

    http://rattomago.wordpress.com/2009/02/18/accessing-filepath-in-html-input-element-via-javascript/

    MfG ChrisB

    --
    Light travels faster than sound - that's why most people appear bright until you hear them speak.