I have FileUpload control on my ASP.NET page and Image control where I show image which is uploaded on server. What I want is for the Image control to show what I choose when I click on Browse in FileUpload control before I upload on server. This way, the user can see what they are uploading.
I am using C# with ASP.NET 4
There’s going to be JavaScript involved with something like this, be aware of that. There’s no setting on the out-of-the-box ASP.NET controls to accomplish this. (Mostly because the standard
input type="file"doesn’t support this.)A quick Google search turned up a jQuery plugin that seems to do the job quite effectively. I checked my web inspector window while adding a file and, sure enough, it doesn’t seem to post to the server prior to displaying the preview.
In their Setup documentation you’ll want the section entitled “Using jQuery File Upload (UI version) with a custom server-side upload handler.” Their wiki also has links to sample ASP.NET code.