Display Below error in Safari.
Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided.
My Code is:
function createObjectURL(object) {
return (window.URL) ? window.URL.createObjectURL(object) : window.webkitURL.createObjectURL(object);
}
This is my Code for image:
function myUploadOnChangeFunction() {
if (this.files.length) {
for (var i in this.files) {
if (this.files.hasOwnProperty(i)) {
var src = createObjectURL(this.files[i]);
var image = new Image();
image.src = src;
imagSRC = src;
$('#img').attr('src', src);
} }
} }
I had the same error for the MediaStream. The solution is set a stream to the srcObject.
From the docs:
The problem is that the keys provided in the loop do not refer to the index of the file.
The output of the above code is:
But what was expected was:
Then the error occurs when the browser tries to execute, for example:
I suggest implementation based on the following code:
I hope this can help someone.
Greetings!
This error is caused because the function
createObjectURL
is deprecated for Google ChromeI changed this:
to this:
This worked for me.
I experienced same error, when I passed to
createObjectURL
raw data:It has to be
Blob
,File
orMediaSource
object, not data itself. This worked for me:Check also the MDN for more info: https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL