Hi
In my application i have a registration page in which FileUpload image preview functionality is required. I implemented below javascript code which is working IE6 but this code is not working on IE7 and firefox so if any budy have some idea please help me i need it in urgent and i am stuck with this problem from last 2 weeks.
And i also tried the web custom control to implement the image preview functionality but this is also not working because i am using master page concept that's why it is not workong, in case of master page what i need to mention here...TargetFormID="Your form name where u want to see the file upload control".
Here is the link to see whole code... http://rebootoff.blogspot.com/2008/04/javascript-image-uploadpreview-without.html
and here is the my javascript code ..
function imgload()
{
var filePath = document.getElementById('<%=ctrlFileUpLoad1.ClientID%>');
var DefaultAd = document.getElementById ('<%=ctrlDefaultAd.ClientID%>');
var path = "file:\/\/\/" + filePath.value;
path = path.toLowerCase();
if (path.substring(0,path.lastIndexOf('.png'))||path.substring(0,path.lastIndexOf('.jpg'))||path.substring(0,path.lastIndexOf('.jpeg'))||path.substring (0,path.lastIndexOf('.gif'))){
var img=document.createElement('img');
img.setAttribute('src',path);
document.getElementById('imageprv').appendChild(img);
}}
// .aspx code
<td>
<asp:FileUpload ID="ctrlFileUpLoad1" runat="server" OnChange="javascript:imgload();" />
<asp:CustomValidator ID="CustomValidator1" ControlToValidate="ctrlFileUpLoad1" Display="dynamic"
ClientValidationFunction="ValidateFile" runat="server" ErrorMessage="Only images are permitted">
</asp:CustomValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ControlToValidate="ctrlFileUpLoad1"
ErrorMessage="Please select the image"></asp:RequiredFieldValidator>
<div id="imageprv" style="width: 475px;">
</div>
</td>