I want to show an uploaded image before clicking on an upload button. I tried but its not working, please check my code below. when I select an image to load then no image will come and after with the help of firebug I found that my code is making weird url's. you can also check fiddle here: http://jsfiddle.net/XdXLJ/
Script
$(document).ready(function(e) {
$('#upload').click(function(){
$('input[type="file"]').show().focus().click().hide();
$('input[type="file"]').change(function(){
var val = $('this').val;
$('.img').append('<img src="'+val+'" />')
})
})
})
HTML
<form id="form1" name="form1" method="post" action="">
<input name="" type="file" />
<div id="upload">Upload</div>
<div class="img"></div>
</form>
Style
#upload{float:left; padding:8px 10px; color:#000; background:#CCC; border:1px solid #000;}
input[type="file"]{display:none;}