Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: .length issue in ie8 and 9
02-12-2014, 02:35 PM #1
- Join Date
- Feb 2014
- Thanked 0 Times in 0 Posts
.length issue in ie8 and 9
Hi I am new to this forum.
I have created a file upload base64 encoder where if a user uploads a document like .doc or .docx it converts it to base64 format onChange. It works fine in most browsers but I am having trouble with ie8 and ie9. In the ie debugger it generates an 'Unable to get property 'length' of undefined or null reference' error. Is there something I need to do specifically for ie9 and and lower?
This is the code I am using:
<p>Select a File to Load:</p>
<input id="inputFileToLoad" type="file" onChange="loadImageFileAsURL();" />
<p>File Contents as DataURL:</p>
<textarea id="textAreaFileContents" style="width:640;height:240;" ></textarea>
var filesSelected = document.getElementById("inputFileToLoad").files;
if (filesSelected.length >0)
var fileToLoad = filesSelected;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
var textAreaFileContents = document.getElementById
textAreaFileContents.innerHTML = fileLoadedEvent.target.result;
02-12-2014, 10:07 PM #2
- Join Date
- Jun 2007
- Thanked 598 Times in 578 Posts
FileReader() wasn't introduced until IE10. If you want to use files in older copies of IE, you'll need to use a flash uploader or use an old-school form upload to put them on a server and then use ajax to get them back into JS land. There are some "stupid IE tricks" that can read certain files if conditions are just right, but these days those methods require changing security settings and should thus be avoided.