Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
<script type="text/javascript">
     function previewImg(path, img) {
          imgPrev = document.images[img];
          imgPrev.src = path;

<asp:FileUpload runat="server" ID="uploadImage"  onchange="previewImg(this.value, 'imgPreview');" />
<br />
<asp:Image ID="imgPreview" name="imgPreviewModify" runat="server" />
Updated 14-Oct-11 9:35am
Ed Nutting 15-Oct-11 7:12am    
Please now learn the difference between publicly accessble files on a web-server and files on someone's home computer. What you have written attempts to show an image that is on the user's computer - I damn well hope nothing in my browser can directly access my files. You need to submit the file to your server through the upload control and then save it server-side and then set the img tag's url to that new file - this will require a page submit or you can do it using AJAX.

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