Can We read client side files using javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • parveen

    Can We read client side files using javascript

    Can We read client side files using javascript? not only text files
  • Thomas 'PointedEars' Lahn

    #2
    Re: Can We read client side files using javascript

    parveen wrote:
    Can We read client side files using javascript? not only text files
    Yes, with XHR, but only from a file: URI to a file: URI, or with a
    privileged script. In MSIE 7+ you are required to use the ActiveXObject
    object instead of XMLHttpRequest for that.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann

    Comment

    • Joost Diepenmaat

      #3
      Re: Can We read client side files using javascript

      parveen <k.parveen@gmai l.comwrites:
      Can We read client side files using javascript? not only text files
      Yes. No. Some. Depending on what you mean.

      --
      Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: Can We read client side files using javascript

        Thomas 'PointedEars' Lahn wrote:
        parveen wrote:
        >Can We read client side files using javascript? not only text files
        >
        Yes, with XHR, but only from a file: URI to a file: URI, or with a
        privileged script. In MSIE 7+ you are required to use the ActiveXObject
        object instead of XMLHttpRequest for that.
        Just in case anyone is interested, the following works from a `http:' URI in
        Fx 2.0.0.13 if the supporting feature is enabled[1]:

        try
        {
        netscape.securi ty.PrivilegeMan ager.enablePriv ilege("Universa lBrowserRead");
        netscape.securi ty.PrivilegeMan ager.enablePriv ilege("Universa lFileRead");
        var x = new XMLHttpRequest( );
        x.open("GET", "file:///C:/AUTOEXEC.BAT", true);
        x.onreadystatec hange = function() {
        if (x.readyState == 4) window.alert(x. responseText);
        };
        x.send(null);
        }
        catch (e)
        {
        e
        }

        It is important that both privileges are requested and granted. Firebug
        then still displays

        | Security Error: Content at http://... may not load or link to
        | file:///C:/AUTOEXEC.BAT.

        but the content of the file is displayed anyway. Code running out of the
        sandbox does not have to request the privileges though, so be careful with
        what extensions you install :)


        PointedEars
        ___________
        [1]
        The MDN Web Docs site provides information about Open Web technologies including HTML, CSS, and APIs for both Web sites and progressive web apps.

        --
        var bugRiddenCrashP ronePieceOfJunk = (
        navigator.userA gent.indexOf('M SIE 5') != -1
        && navigator.userA gent.indexOf('M ac') != -1
        ) // Plone, register_functi on.js:16

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: Can We read client side files using javascript

          The Magpie wrote:
          Thomas 'PointedEars' Lahn wrote:
          >parveen wrote:
          >>Can We read client side files using javascript? not only text files
          >Yes, with XHR, but only from a file: URI to a file: URI, or with a
          >privileged script. In MSIE 7+ you are required to use the ActiveXObject
          >object instead of XMLHttpRequest for that.
          >>
          You can with XMLHttpRequest, Pointed. It doesn't really care what type
          the files are as long as they are text-content (not binary).
          It would appear you are replying to something I have not written.


          PointedEars

          Comment

          Working...