image upload preview
some jQuery to preview the image being uploaded on the page
by Oliver Kelso
HTML
<form id="form1" runat="server">
<input type='file' id="imgInp" />
</form>
<img id="preview" src="#" alt="your image" />
CSS
body {
background:#111;
color:#FFF;
}
#preview {
width:100%;
display:none;
float:left;
clear:both;
}
JavaScript
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#preview').attr('src', e.target.result).fadeIn("slow");
}
reader.readAsDataURL(input.files[0]);
}
}
$("#imgInp").change(function () {
readURL(this);
});