HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Display Image preview before upload</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
function showImagePreview(input) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function (e) {
$('#imgPreview').attr('src', e.target.result);
}
filerdr.readAsDataURL(input.files[0]);
}
}
</script>
</head>
<body>
<form id="form1">
<h1>Display Image preview before upload</h1>
<div>
<input type="file" onchange="showImagePreview(this)" />
<br /><br />
<img id="imgPreview" alt="Preview image" width="400" />
</div>
</form>
</body>
</html