How to select local file and display its content

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

    How to select local file and display its content

    Hi all,

    my application produces a log file in XML and I want my users to be
    able to see this log file nicely formatted through either IE or FF,
    but there is only client side code (no web connection). I have written
    the code in JS in an HTML page that formats the XML file. I use the
    following to load any file from the disk and display the contents:

    <fieldset>
    <legend>Pleas e load only valid xml log files</legend>
    <form method="POST" >
    <input type="file" name="loadfile" >
    <input type="button" name="submit" value="submit"
    onClick="LoadFi le(this.form.lo adfile.value)">
    </form>
    </fieldset>

    however this.form.loadf ile.value contains only the file name and not
    the full path. Searching the net I found that it is supposed to be
    this way and there is nothing one can do about it for security
    reasons. Are there any other ways to get a dialog to select a file and
    then get the full path?

    Thanks a lot!

    -- dimitris
  • GArlington

    #2
    Re: How to select local file and display its content

    On Sep 18, 12:28 pm, jma <junkmailav...@ yahoo.comwrote:
    Hi all,
    >
    my application produces a log file in XML and I want my users to be
    able to see this log file nicely formatted through either IE or FF,
    but there is only client side code (no web connection). I have written
    the code in JS in an HTML page that formats the XML file. I use the
    following to load any file from the disk and display the contents:
    >
    <fieldset>
    <legend>Pleas e load only valid xml log files</legend>
    <form method="POST" >
    <input type="file" name="loadfile" >
    <input type="button" name="submit" value="submit"
    onClick="LoadFi le(this.form.lo adfile.value)">
    </form>
    </fieldset>
    >
    however this.form.loadf ile.value contains only the file name and not
    the full path. Searching the net I found that it is supposed to be
    this way and there is nothing one can do about it for security
    reasons. Are there any other ways to get a dialog to select a file and
    then get the full path?
    >
    Thanks a lot!
    >
    -- dimitris
    AFAIK: html files CAN NOT accept "post" requests and you can NOT
    upload file with "get" method...
    Am I understanding it correctly that your log file is on user's local
    file system? If so, I suggest you use xsl(t) to display the content of
    xml locally...

    Comment

    • jma

      #3
      Re: How to select local file and display its content

      On Sep 18, 3:29 pm, GArlington <garling...@tis cali.co.ukwrote :
      On Sep 18, 12:28 pm, jma <junkmailav...@ yahoo.comwrote:
      >
      >
      >
      Hi all,
      >
      my application produces a log file in XML and I want my users to be
      able to see this log file nicely formatted through either IE or FF,
      but there is only client side code (no web connection). I have written
      the code in JS in an HTML page that formats the XML file. I use the
      following to load any file from the disk and display the contents:
      >
      <fieldset>
      <legend>Pleas e load only valid xml log files</legend>
      <form method="POST" >
      <input type="file" name="loadfile" >
      <input type="button" name="submit" value="submit"
      onClick="LoadFi le(this.form.lo adfile.value)">
      </form>
      </fieldset>
      >
      however this.form.loadf ile.value contains only the file name and not
      the full path. Searching the net I found that it is supposed to be
      this way and there is nothing one can do about it for security
      reasons. Are there any other ways to get a dialog to select a file and
      then get the full path?
      >
      Thanks a lot!
      >
      -- dimitris
      >
      AFAIK: html files CAN NOT accept "post" requests and you can NOT
      upload file with "get" method...
      Am I understanding it correctly that your log file is on user's local
      file system? If so, I suggest you use xsl(t) to display the content of
      xml locally...
      Hi GArlington

      you are absolutely correct, but the thing is that I want to display
      the XML as a tree with branches that spread and collapse.
      Unfortunatelly this I cannot do with XSLT... even if I manage to put
      together something with CDATA, FF will not use it...

      thanks for the reply!

      -- dimitris

      Comment

      • Chris Riesbeck

        #4
        Re: How to select local file and display its content

        jma wrote:
        On Sep 18, 3:29 pm, GArlington <garling...@tis cali.co.ukwrote :
        >On Sep 18, 12:28 pm, jma <junkmailav...@ yahoo.comwrote:
        .... snip ...
        >>
        >>Hi all,
        >>my application produces a log file in XML and I want my users to be
        >>able to see this log file nicely formatted through either IE or FF,
        >>but there is only client side code (no web connection).
        >
        Hi GArlington
        >
        you are absolutely correct, but the thing is that I want to display
        the XML as a tree with branches that spread and collapse.
        Unfortunatelly this I cannot do with XSLT... even if I manage to put
        together something with CDATA, FF will not use it...
        >
        thanks for the reply!
        >
        -- dimitris
        Why not just open the XML files directly in IE or FF? Both display XML
        in interactive form.

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: How to select local file and display its content

          Chris Riesbeck wrote:
          Why not just open the XML files directly in IE or FF? Both display XML
          in interactive form.
          It is hardly user-friendly, though.


          PointedEars
          --
          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

          • jma

            #6
            Re: How to select local file and display its content

            On 18 Óåðô, 20:51, Chris Riesbeck <Chris.Riesb... @gmail.comwrote :
            jma wrote:
            On Sep 18, 3:29 pm, GArlington <garling...@tis cali.co.ukwrote :
            On Sep 18, 12:28 pm, jma <junkmailav...@ yahoo.comwrote:
            ... snip ...
            >
            >Hi all,
            >my application produces a log file in XML and I want my users to be
            >able to see this log file nicely formatted through either IE or FF,
            >but there is only client side code (no web connection).
            >
            Hi GArlington
            >
            you are absolutely correct, but the thing is that I want to display
            the XML as a tree with branches that spread and collapse.
            Unfortunatelly this I cannot do with XSLT... even if I manage to put
            together something with CDATA, FF will not use it...
            >
            thanks for the reply!
            >
            -- dimitris
            >
            Why not just open the XML files directly in IE or FF? Both display XML
            in interactive form.
            Hi Chris

            yes, but polluted with all the tags... actually what I want is very
            simple, open the XML files and get the same tree view I get in any
            browser but only text - no tags. It turns out it is pretty impossible
            to do that.... I had to do quite some coding to get an html page and a
            javascript do the job. Now I want to do the simple thing - have a text
            field and a button to open the file, but this is not possible - only
            if the file is in the same directory as the html file it works (of
            course i use the input field above to get the nice file search
            dialog). So the simplest of all things turns out to be a meander of
            technologies... .

            thanks for the reply!

            -- dimitris

            Comment

            • jma

              #7
              Re: How to select local file and display its content

              On 18 Óåðô, 23:51, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
              wrote:
              Chris Riesbeck wrote:
              Why not just open the XML files directly in IE or FF? Both display XML
              in interactive form.
              >
              It is hardly user-friendly, though.
              >
              PointedEars
              --
              var bugRiddenCrashP ronePieceOfJunk = (
                  navigator.userA gent.indexOf('M SIE 5') != -1
                  && navigator.userA gent.indexOf('M ac') != -1
              )  // Plone, register_functi on.js:16
              Hi PointedEars,

              exactly my point.... any other ideas to get around all this cumbersome
              mess?

              thanks for the answer!

              -- dimitris

              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: How to select local file and display its content

                jma wrote:
                Thomas 'PointedEars' Lahn wrote:
                >Chris Riesbeck wrote:
                >>Why not just open the XML files directly in IE or FF? Both display XML
                >>in interactive form.
                >It is hardly user-friendly, though.
                >[...]
                >
                exactly my point.... any other ideas to get around all this cumbersome
                mess?
                XSLT should work. Probably you are doing something wrong there. That would
                be off-topic here, though, unless you try to use a host object for the
                transformation.

                Please trim your quotes, don't quote signatures (unless you refer to them).

                <http://jibbering.com/faq/>


                PointedEars
                --
                Use any version of Microsoft Frontpage to create your site.
                (This won't prevent people from viewing your source, but no one
                will want to steal it.)
                -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

                Comment

                • jma

                  #9
                  Re: How to select local file and display its content

                  Hi Thomas,
                  XSLT should work.  Probably you are doing something wrong there.  That would
                  be off-topic here, though, unless you try to use a host object for the
                  transformation.
                  This is very well possible - I am not very familiar with xslt. However
                  I tried with simple things and found out that the functionality I need
                  must be implemented with JS and should be in a CDATA block which FF
                  simply ignores...
                  Please trim your quotes, don't quote signatures (unless you refer to them).
                  Sorry

                  -- dimitris

                  Comment

                  • Bart Van der Donck

                    #10
                    Re: How to select local file and display its content

                    GArlington wrote:
                    AFAIK: html files CAN NOT accept "post" requests
                    They can. A developer could make the choice to parse .htm(l)
                    extensions as CGI-script. It's then a matter how the web server is
                    configured what happens with POST-ed form data. In so far I know it is
                    not too usual though, because nothing can be done with the POST-ed
                    data from inside the document (HTML, javascript).
                    and you can NOT upload file with "get" method...
                    In this case, the convention is that the name of the file in the input
                    field is passed in the query-string.

                    --
                    Bart

                    Comment

                    Working...