Load contents of a text file into a text box

  • Thread starter Thread starter Jeremy Chapman
  • Start date Start date
J

Jeremy Chapman

How can I display a file open dialog by clicking a button in an aspx page,
have the user select a text file then display the contents into a control
such as a text box
 
I don't know if you could open a file using client-side script. This
don't sound right from a security point of view. However, you can have
the user upload the file to your webform. Your webform then opens the
file on the server, reads its contents, and populate it to the textbox
and return to the client.

The following is some sample HTML code that will show a open file
dialog box on the client-side and allow the user to upload a file.

********************************************
<html>
<body>
<form name="form1" action="form1" enctype="multipart/form-data"
method="post">
<p>
Type some text (if you like):<br>
<input type="text" name="textline" size="30">
</p>
<p>
Please specify a file, or a set of files:<br>
<input type="file" name="datafile">
</p>
<p>
<input type="submit" value="Send">
</p>
</form>
</body>
</html>
********************************************

Tommy,
 
Back
Top