Skip to content

Image Uploading and Instant Preview in Asp.Net MVC

jothi kumar

Asked Jul 21, 2014, 12:14 AM EDT1 answer
Share
LinkedInX
hi to all,
                  here , i want to upload and instant preview. here i shown my jquery it occur some error can you resolve me and give some tips to upload and instant preview or give another methods for upload and preview


JavaScript
script type="text/javascript">     function PreviewImage(e) {         var preview = document.getElementById('image');         if (e.target.files && e.target.files[0]) {             var reader = new FileReader();             reader.onload = function (e) {                 preview.setAttribute('src', e.target.result);             }             reader.readAsDataURL(e.target.files[0]);         }         else {             preview.setAttribute('src', '/Attachment/Profile/User.png');         }     }      $(function () {         $('#UserProfilePhoto').change(function (e) {             PreviewImage(e);         });     });  </script>

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    You can use http://plugins.jquery.com/uploadfile/ plugin for the same, it's easy to use
    0