Showing posts with label image preview. Show all posts
Showing posts with label image preview. Show all posts

Monday 12 May 2014

Image uploading Instant preview




<img src="http://www.designofsignage.com/application/symbol/building/image/600x600/no-photo.jpg" width='200px' height='200px' id="preview" title="No Image"><br><br>
<input type="file"  name="postimage" id="postimage" onchange="readURL(this,200,200)" >
<script type='text/javascript' src='http://code.jquery.com/jquery-1.11.1.min.js'></script>
<script type='text/javascript'>
function readURL(input,w,h) {
 if (input.files && input.files[0]) {
  var reader = new FileReader();
  reader.onload = function (e) {
   $('#preview').attr('src', e.target.result);
   $("#preview").attr("width",w);
   $("#preview").attr("height",h);
  }
  reader.readAsDataURL(input.files[0]);
 }
}
</script>