ASP.Net File Upload - Tricky One
Hi all,
I know how to implement fileupload in ASP.Net but i have a little bit tricky situation over here:
I have a classic ASP.Net webform for saving and editing data for a customer. I also have a HtmlInputFile (input type=file) control that allows me to upload a picture for any given customer. Now my problem is that when editing the customer details, i should be able to view the path of the picture currently saved for a customer and when clicking on a browse button to be able to select another image file. the problem is that the user wants to see only 2 controls, namely a textbox for the file path and a browse button. but since the Filename property of an HtmlInputFile is readonly i cannot use that very same control to display the path of the file as saved in the database. One work around for this could have been to have a classic textbox and a browse button instead of the input type file control, but then when clicking on the browse button how can the browse dialog of the input type file or HtmlInputFile be shown?
I hope its clear enough to yield a few answers. thanx in advance.
Re: ASP.Net File Upload - Tricky One
You have to use a file input control if you want to upload - there is no way of implementing the same functionality with a standard button. You could try the following but as far as I remember it only works perfectly for Internet Explorer.
Place a textbox and file input control on the page, set the width (in CSS) for the file input control so that only the browse button is visible. That should look like you want it. The only draw back of this is that in FireFox etc. the file location box still appears (you cannot hide it due to security issues).
Otherwise I don't think what you want to do is possible.
DJ
Re: ASP.Net File Upload - Tricky One
thanx DJ i'll be trying that and see if i can use it as a work around.
cheers.