Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
C#
<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.

 
Share this answer
 
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>
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900