I want to show contents of uploaded file in html, I can just upload a text file. My example.html:
<html xmlns="http://www.w3.org/1999/xhtml" >
<p>
Please specify a file, or a set of files:<br>
<input type="file" name="datafile" size="40">
</p>
<textarea id="2" name="y" style="width:400px;height:150px;"></textarea>
</html>
How can I show contents of any uploaded text file in textarea shown below?
Here's one way:
HTML
JavaScript
I've came here from google and was surprised to see no working example.
You can read files with FileReader API with good cross-browser support.
See fully working example below.
Try this.
HTML
JS
Demo