JavaScript readAsDataurl is not a function

In Gecko / Firefox, I received an error message:

TypeError: fr.readAsDataurl is not a function

Using the following JavaScript:

var fr = new FileReader(); fr.readAsDataURL(files[i]); 
+5
source share
1 answer

As it turns out, someone from Mozilla created an outdated readAsDataurl method with an incorrect letter shell, and since JavaScript is case sensitive, I just had to use the readAsDataurl method (upper case URL):

 if (fr.readAsDataURL) {fr.readAsDataURL(files[i]);} else if (fr.readAsDataurl) {fr.readAsDataurl(files[i]);} 

Please note that the standard / correct casing method is determined first. If you want your code to run as fast as possible, performance will improve over time as standards support improves.

+7
source

All Articles