Solved

How to select a directory using HTML

Posted on 2003-10-21
12
341 Views
Last Modified: 2008-01-16
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
0
Comment
Question by:aarschie
12 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 9595619
In just HTML no, and in JSP I don't think so.
Heres a link that may be handy
http://www.servlets.com/cos/index.html

Incidentally you cant set the value of a File tag.
0
 
LVL 1

Expert Comment

by:paStiSSet
ID: 9595812
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 :)
0
 
LVL 2

Expert Comment

by:miskate
ID: 9597064
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.
0
 
LVL 3

Expert Comment

by:savalou
ID: 9599804
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.
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9599997
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
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:aarschie
ID: 9610845
Vinny,
To save a file on the users machine.
Thanks
Arschie
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9610959
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.FileSystemObject")
  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
0
 

Author Comment

by:aarschie
ID: 9611122
I am not able to run this.
It's giving error on page.

Probably it is due to Active X
Arschie
0
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 500 total points
ID: 9613615
Hi,
   The above will work only if:
1) you are running in a windows environment and
2) you have Scrrun.dll in the windows\system32 folder

Vinny
0
 

Expert Comment

by:wilslm
ID: 9844487
I dont think html is able to process this kind of things. i dont know about JSP but I'm sure php does this
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 10428506
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
spacing 5 57
Login area of a page 4 32
html form to write data to csv 24 97
bootstrap footer centering and expand problems 7 29
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now