aarschie
asked on
How to select a directory using HTML
I am writing a HTML which basically selects a file to be parsed (eventually I am calling a servlet). This works fine with :
<input type=file name=uploadfile value='SelectFile'>
I would like to store the result in a directory as a .txt file. I am not able to select a directory where from my HTML. Does anyone have an idea how to do it either inHTML or JSP..
Thanks
Aarschie
<input type=file name=uploadfile value='SelectFile'>
I would like to store the result in a directory as a .txt file. I am not able to select a directory where from my HTML. Does anyone have an idea how to do it either inHTML or JSP..
Thanks
Aarschie
i know you can use a php script, but i can't type it. ask in the php directory, is very easy, hope experts answer quickly :)
for security reasons you cannot preset the contents of a file input type. You also cannot change its value using javascript. This is to prevent websites uploading files from your computer that you haven't said they could upload.
You may be able to do it using a java applet or activex component or some other plugin.
You may be able to do it using a java applet or activex component or some other plugin.
If the servlet that's processing your file could send the results back with a mime-type other than text, so that the browser asks the user what to do with it, like when you download software, that might be one way to go.
Hi,
Are you asking how to save the uploaded file to a particular directory on the server? Or how to save a file (not necessarily the uploaded file) to a directory on the user's machine?
Vinny
Are you asking how to save the uploaded file to a particular directory on the server? Or how to save a file (not necessarily the uploaded file) to a directory on the user's machine?
Vinny
ASKER
Vinny,
To save a file on the users machine.
Thanks
Arschie
To save a file on the users machine.
Thanks
Arschie
Hi Arschie,
maybe you can adapt this:
function doit(contents)
{
var contents = document.a.c.value;
var txtFile = document.a.b.value;
var fso, f1, ts, s
var ForWriting= 2;
fso = new ActiveXObject("Scripting.F ileSystemO bject")
ts = fso.OpenTextFile(txtFile, ForWriting)
ts.WriteLine(contents)
ts.Close()
}
//-->
</script>
</head>
<body>
<form name="a">
<input type="file" name="b">
<textarea name="c"></textarea>
<input type="button" value="do it" onclick='doit()'>
</form>
</body>
</html>
Vinny
maybe you can adapt this:
function doit(contents)
{
var contents = document.a.c.value;
var txtFile = document.a.b.value;
var fso, f1, ts, s
var ForWriting= 2;
fso = new ActiveXObject("Scripting.F
ts = fso.OpenTextFile(txtFile, ForWriting)
ts.WriteLine(contents)
ts.Close()
}
//-->
</script>
</head>
<body>
<form name="a">
<input type="file" name="b">
<textarea name="c"></textarea>
<input type="button" value="do it" onclick='doit()'>
</form>
</body>
</html>
Vinny
ASKER
I am not able to run this.
It's giving error on page.
Probably it is due to Active X
Arschie
It's giving error on page.
Probably it is due to Active X
Arschie
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I dont think html is able to process this kind of things. i dont know about JSP but I'm sure php does this
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: VincentPuglia {http:#9613615}
Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
mplungjan
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: VincentPuglia {http:#9613615}
Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
mplungjan
EE Cleanup Volunteer
Heres a link that may be handy
http://www.servlets.com/cos/index.html
Incidentally you cant set the value of a File tag.