Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Browse

Status
Not open for further replies.

dcushnie

Programmer
Feb 2, 2005
28
CA
So what I want is simply a button on a webpage that opens a local file browse dialog.
I don't want to upload the file anywhere, I just want it's path.
I know there is a file upload control but I don't want to use it because I don't want the textbox that goes with it and I also don't want the button to say "Browse".
I tried to use System.Windows.Forms.OpenFileDialog but it throws this error: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.

Is there anyway to do what I want?
 
You can't do this using javascript. You might have some luck with an ActiveX control - which will work in IE for Windows only.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
You can use css to hide the file upload control and then use JavaScript to ".click()" the control to display the dialog. However, in newer Internet Explorer browsers this may not work unless it's in a separate IFRAME. Don't ask me why, I just heard that Google uses this work around for gmail attachments.

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top