Here is my problem, i have this little code to display img that i'm uploading LIVE without reload, but it works only with one img because readURL(input)
doesn't have a class and works directly from noname-input, and when i'm adding a class readURL(input.joint)
, it drops error! Here is my code:
<input class=joint type='file' id=imgInp />
<img style=width:45px id=blah src=# alt=your image />
<script type=text/javascript>
function readURL(input) {
if (input.filers && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$(#imgInp).change(function(){
readURL(this);
});
</script>
I need to add some id or class to this jquery function to make it unique to every input.
What i'm trying to do:
<input class=joint type='file' id=imgInp />
<img style=width:45px id=blah src=# alt=your image />
<script type=text/javascript>
function readURL(input.joint) {
if (input.joint.filers && input.joint.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.joint.files[0]);
}
}
$(#imgInp).change(function(){
readURL(this);
});
</script>
<input class=file2 type='file' id=imgInp />
<img style=width:45px id=blah src=# alt=your image />
<script type=text/javascript>
function readURL(input.file2) {
if (input.file2.filers && input.file2.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.file2.files[0]);
}
}
$(#imgInp).change(function(){
readURL(this);
});
</script>