I have a HTML5 page containing input file upload control. I am using filereader to read a text file and it works absolutely fine when I hoST the HTML page in IIS with IE10. But when I upload the HTML page in CRM 2013 as web resource and call the page (opens
in a new window) from a link in CRM 2013 Ribbon, it fails to read the file and throws error "Filreader not supported with this browser", though CRM is also opened in IE 10. I am using following code. Not sure whats wrong with Filereader compatibility
with CRM 2013. Any suggestion?
<script
type="text/javascript">
function checkfile(sender) {
var validExts =
".csv";
var fileExt = sender.value;
fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
if (validExts.indexOf(fileExt) < 0) {
alert("Invalid
file selected, valid files is of " +
validExts +
" types.");
return
false;
}
else {
handleFiles(sender.files);
// return true;
}
}
function handleFiles(files) {
//
Check for the various File API support.
if (window.FileReader) {
// FileReader are supported.
getAsText(files[0]);
}
else {
alert('FileReader
are not supported in this browser.');
}
}
function getAsText(fileToRead) {
var reader =
new FileReader();
// Read file into memory as UTF-8
reader.readAsText(fileToRead);
// Handle errors load
reader.onload = loadHandler;
reader.onerror = errorHandler;
}
function
loadHandler(event) {
var csv = event.target.result;
processData(csv);
}
</script>
<head>
<meta
charset="utf-8"
/>
<!-- <meta http-equiv="X-UA-Compatible"
content="IE=10">-->
<title></title>
</head>
<body>
<input
type="file"
name="datafile"
accept=".csv"
onchange="checkfile(this);"
/>
</body>
</html>