Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reactjs URL.createObjectURL is not a function

I have this loadfile function that loads an image after uploading.. I want to convert to get its URL path... but im receiving an error "URL.createObjectURL is not a function" but when i console the e.target.files[0], I can view the file in console.. can any one help me?

 loadFile: function(e){
    var output = document.getElementById('output');
    output.src = URL.createObjectURL(e.target.files[0]);
 }
like image 405
treb Avatar asked May 13 '16 10:05

treb


1 Answers

This most definitely is unrelated to react. The reason you're likely experiencing this is the createObjectURL is still a part of a working draft and has not yet been finalized, and as such you won't have much browser compatibility. See the below compatibility chart to see if your browser supports the feature:

https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL#Browser_compatibility

like image 167
sheeldotme Avatar answered Sep 25 '22 15:09

sheeldotme