How to select local file and display its content

J

jma

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>Please load only valid xml log files</legend>
<form method="POST" >
<input type="file" name="loadfile">
<input type="button" name="submit" value="submit"
onClick="LoadFile(this.form.loadfile.value)">
</form>
</fieldset>

however this.form.loadfile.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
 
G

GArlington

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>Please load only valid xml log files</legend>
<form method="POST" >
<input type="file" name="loadfile">
<input type="button" name="submit" value="submit"
onClick="LoadFile(this.form.loadfile.value)">
</form>
</fieldset>

however this.form.loadfile.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...
 
J

jma

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
 
C

Chris Riesbeck

jma said:
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.
 
T

Thomas 'PointedEars' Lahn

Chris said:
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
 
J

jma

... snip ...






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
 
J

jma

It is hardly user-friendly, though.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
)  // Plone, register_function.js:16

Hi PointedEars,

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

thanks for the answer!

-- dimitris
 
T

Thomas 'PointedEars' Lahn

jma said:
Thomas said:
Chris said:
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
 
J

jma

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
 
B

Bart Van der Donck

GArlington said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,170
Latest member
Andrew1609
Top