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.
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.