Click here to Skip to main content
14,638,198 members
Rate this:
Please Sign up or sign in to vote.
See more:
i am using wizard in asp.net .
i have image upload on all steps
for display image i am using this script shown below
<script type="text/javascript">
        function previewFile() {
            var preview = document.querySelector('#<%=ImgFmlyPhoto.ClientID %>');
            var file = document.querySelector('#<%=FUFmlymbr.ClientID %>').files[0];
            var reader = new FileReader();

            reader.onloadend = function () {
                preview.src = reader.result;
            }

            if (file) {
                reader.readAsDataURL(file);

            } else {
                preview.src = "";
            }
        }
</script>

<asp:FileUpload ID="FUFmlymbr" runat="server" onchange="previewFile()" type="file" name="file"/>

problem is when i browse image on step1 picture is displayed but when i go to step 2 and again i come to step 1 so there is no image.

please help .............
Posted
Updated 16-Sep-14 2:01am
v2
Comments
Member 11014751 15-Sep-14 5:52am
   
Any One please Help
ZurdoDev 15-Sep-14 8:09am
   
This does not make much sense. You'll have to debug it and find out exactly what is happening.
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Use the Sample Code as :

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Preview Image before upload</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
function Preview(input) {
if (input.files && input.files[0]) {
var filerdr = new FileReader();
filerdr.onload = function(e) {
$('#imgprvw').attr('src', e.target.result);
}
filerdr.readAsDataURL(input.files[0]);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="file" name="filUpload" id="filUpload" onchange="Preview(this)" />
</form>
</body>
</html>
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100