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 experienced the same error, when I passed raw data to
createObjectURL:It has to be a
Blob,FileorMediaSourceobject, 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
UPDATE
Back in the day we could also use
createObjectURL()method with MediaStream objects. This use has been dropped by the specs and by browsers.If you need to set a MediaStream as the source of an HTMLMediaElement just attach the
MediaStreamobject directly to thesrcObjectproperty of the HTMLMediaElement e.g.<video>element.However, if you need to work with
MediaSource,BloborFile, you still have to create ablob://URL withURL.createObjectURL()and assign it toHTMLMediaElement.src.Read more details here: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject