tags:

views:

23

answers:

1

Hi,

I'm using an asp:FileUpload control to give the user the chance to look for an image on the hard drive, once the user has chosen the image, after a button is pressed, I want to display the image in an asp:Image control.

I've been trying to get the full path of the file but I can't get it, I'm using Path.GetFullPath(FileUpload.FileName) but I'm getting a totally different path, not the path to the image that the user selected.

I was reading that I need to set the src attribute of the asp:Image control to be an aspx page which is going to return the image, and then I have to write the bytes from the image to the response but I'm not sure how to do this (I'm a newbie in web development), I don't know what should I put in my event, in the code behind, or what code should I place on the aspx page that will return the image, neither how to call the aspx page with the image from the event handler.

Can anyone show me a good example on how to achieve this.

Many Thanks!

+2  A: 

The issue here is the file being uploaded resides on the client computer where the asp:image control is looking for an image on the server computer.

What you should be doing is on the form submit/button click save the file into the application folder then reference that file with your asp:image control.

d1k_is
Thanks for the answer, that is certainly another option, to save the image and then load it from the saved location, but I was looking to stream the image to the control, in fact I managed to do it, this post helped me a lot http://forums.asp.net/p/1265564/3699496.aspx hope this help others.
Vic