It's not possible to do this (at least, not with a server-side language) because all of the code is processed BEFORE the page is loaded. So, that wouldn't work.
You could use ActiveX Objects. The problem with them is that they are only on IE4+ on the Windows platform and that they show an alert that the user has to agree with for the action to perform. If you really wanted to do it, though, you could. Here's the script:
<head>
<title>Reading Files</title>
<script type="text/javascript">
var fsoObj=new ActiveXObject("Scripting.FileSystemObject");
function readFile(path) {
var readFile=fsoObj.OpenTextFile(path);
document.forms[0].contents.value=readFile.ReadAll();
}
</script>
</head>
<body>
<form>
<textarea name="contents" rows="23" cols="60"></textarea>
<br /><input type="file" name="path" onchange="readFile(this.value);" />
</form>
</body>
Hope that helps!
Happy coding! 🙂