I was working on something and the question was answered, but i need a different use for it. I have a jsFiddle of how it works. http://jsfiddle.net/TbZzH/4/
that is fine and dandy, but when i do it in my code, it will tell me that data.files[0] does not work, and is said to be undefined. It also does not recognize the FileReader() object.
My code is as follows, using jsFiddle as an example I worked from.
$(function(){
$("input[type='file'].attribute").on("change", function () { updateDesigner(this); });
});
function updateDesigner(input){
var t = input;
if ($(input).attr("type") == 'file'){
try{
var data = $(t)[0];
var file = data.files[0]; //<------ FAILS HERE. .files is an undefined attr.
var reader = new FileReader(); //<--- working around it, doesnt understand this object as well
reader.onload = function (e) {
value = e.target.result;
}
reader.readAsDataURL(file);
}catch(errrrr){
alert("error putting image into image tag: "+errrrr.toString());
}
}
srcFunction(value); //takes the value and applied it to the src attr of the image tag.
}
I want to pipe the data into value and everything would run smooth, but i am not sure what is going on.