Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #9172

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

From kiran <kiranmbadi@gmail.com>
Newsgroups comp.lang.javascript
Subject File API HTML 5 Getting undefined for window.URL.createObjectURL
Date 2011-12-12 19:46 -0800
Organization http://groups.google.com
Message-ID <10277146.1602.1323748010365.JavaMail.geo-discussion-forums@yqfd21> (permalink)

Show all headers | View raw


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[i];
//	 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.

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar | Unroll thread


Thread

File API HTML 5 Getting undefined for window.URL.createObjectURL kiran <kiranmbadi@gmail.com> - 2011-12-12 19:46 -0800
  Re: File API HTML 5 Getting undefined for window.URL.createObjectURL kiran <kiranmbadi@gmail.com> - 2011-12-15 20:48 -0800

csiph-web