File API HTML 5 Getting undefined for window.URL.createObjectURL

K

kiran

I have this below code for displaying and previewing images,

function previewimage(){
console.log("function is working");
var myfiles = document.getElementById("idimgup");
var files = myfiles.files;
var file;
for (var i = 0; i < files.length; i++) {
var file = files;
// alert(file.name);
console.log("The name of the file is:",file.name);
// alert(file.lastModifiedDate);
console.log("The lastmodifiedDate of the file is:",file.lastModifiedDate);
// alert(file.size);
console.log("The size of the uploaded file in bytes is:",file.size);
// alert(file.type);
console.log("The content type of the uploaded file is:",file.type);
var objectURL = window.URL.createObjectURL(file);


// var reader = new FileReader();
// reader.onload = function (e) {
document.getElementById("idimg").src = objectURL;
document.getElementById("idimg").onload=function(){
window.URL.revokeObjectURL(objectURL);
}

// if (document.getElementById("idimgup").files.length === 0) { return; }
// var file = document.getElementById("idimgup").[=files[0];
alert("checking for function");
// reader.readAsDataURL(file);
// }
}
}
It works in FF 8.0 but for some reasons it does not work in chrome/safari/opera.They all say undefined for window.URL.createObjectURL.

I am totally lost here.idimgup is input file id and idimg is image placeholder where i need to display images.
Appreciate some suggestions.
 
K

kiran

Can someone help here.I am able to make it work on chrome/opera but no luck with safari on windows ? Any suggestions pls
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top