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


Groups > comp.lang.javascript > #9172 > unrolled thread

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

Started bykiran <kiranmbadi@gmail.com>
First post2011-12-12 19:46 -0800
Last post2011-12-15 20:48 -0800
Articles 2 — 1 participant

Back to article view | Back to comp.lang.javascript


Contents

  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

#9172 — File API HTML 5 Getting undefined for window.URL.createObjectURL

Fromkiran <kiranmbadi@gmail.com>
Date2011-12-12 19:46 -0800
SubjectFile API HTML 5 Getting undefined for window.URL.createObjectURL
Message-ID<10277146.1602.1323748010365.JavaMail.geo-discussion-forums@yqfd21>
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.

[toc] | [next] | [standalone]


#9312

Fromkiran <kiranmbadi@gmail.com>
Date2011-12-15 20:48 -0800
Message-ID<19787756.3.1324010907667.JavaMail.geo-discussion-forums@vbjs5>
In reply to#9172
Can someone help here.I am able to make it work on chrome/opera but no luck with safari on windows ? Any suggestions pls

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web