Skip to content

Instantly share code, notes, and snippets.

@kalexander
Created May 14, 2013 20:14
Show Gist options
  • Save kalexander/5579118 to your computer and use it in GitHub Desktop.
Save kalexander/5579118 to your computer and use it in GitHub Desktop.
playing with file contents on the client side....
<html>
<body>
<form name="uploadForm">
<input id="uploadFile" type="file" name="uploadFile" onchange="performFilePoop();" />
</form>
<script>
function performFilePoop(){
var files = document.getElementById("uploadFile").files
if(files.length == 1){
var fileReader = new FileReader()
fileReader.onload = function(event){
alert(event.target.result)
}
alert(files[0].name)
fileReader.readAsText(files[0])
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment