By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 1,486 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

Button to launch "Open File" Dialogue

P: n/a
Hi all,

I want to put a button on a page, and when the user clicks it, the standard
Windows "Open File" dialogue box opens, and the user can browse/select a
file on their PC. Having selected a file, the user clicks Open, and I then
want to capture the file path and name in a string variable. Finally, I
want to upload the file to the server.

BUT: I don't want to use an <input type="file"> control.

Can this be done?

Cheers,

MG
Nov 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi

input type="file" is the only way... well maybe...
http://fileup.softartisans.com/default.aspx?PageID=122
you can read the contents of the input no problem but you cant set it
And why capture it in a variable as its already in the input....

How to read its value
<input type="file" name="f1" onpropertychange="alert(this.value)">
<input type="file" name="f1" onpropertychange="this.form.myTextInput.value =
this.value">
And if you have the input type=file hidden and use regular button to popup
( // Example
<input type="file" name="f1" style="visibility:hidden">
<input type="button" onclick="this.form.f1.click()">
)
the filedialog you will get Access denied onsubmit
So...

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"Mr Gordonz" <pa**@mobius.net.au> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I want to put a button on a page, and when the user clicks it, the standard Windows "Open File" dialogue box opens, and the user can browse/select a
file on their PC. Having selected a file, the user clicks Open, and I then want to capture the file path and name in a string variable. Finally, I
want to upload the file to the server.

BUT: I don't want to use an <input type="file"> control.

Can this be done?

Cheers,

MG

Nov 17 '05 #2

P: n/a
"Mr Gordonz" <pa**@mobius.net.au> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I want to put a button on a page, and when the user clicks it, the standard Windows "Open File" dialogue box opens, and the user can browse/select a
file on their PC. Having selected a file, the user clicks Open, and I then want to capture the file path and name in a string variable. Finally, I
want to upload the file to the server.

BUT: I don't want to use an <input type="file"> control.


Curiosity: why not? You've just described the functionality of <input
type="file">!
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com
Nov 17 '05 #3

P: n/a
Hi John,

I guess you could call it pig-headedness on my part! I like to think of it
as "because the mountain was there". It is not a big deal, but I would like
to know one way or another if it is possible - and if it is possible, how is
it done.

I strongly suspect it can't be done (at least, not without great
difficulty) - but if someone can prove me wrong, go right ahead - I would
thank you for it!

Cheers,

MG

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"Mr Gordonz" <pa**@mobius.net.au> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I want to put a button on a page, and when the user clicks it, the standard Windows "Open File" dialogue box opens, and the user can browse/select a
file on their PC. Having selected a file, the user clicks Open, and I then want to capture the file path and name in a string variable. Finally, I
want to upload the file to the server.

BUT: I don't want to use an <input type="file"> control.


Curiosity: why not? You've just described the functionality of <input
type="file">!
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #4

P: n/a
In news:%2***************@TK2MSFTNGP12.phx.gbl,
Mr Gordonz <pa**@mobius.net.au> typed:
: Hi John,
:
: I guess you could call it pig-headedness on my part! I like to think
: of it as "because the mountain was there". It is not a big deal, but
: I would like to know one way or another if it is possible - and if it
: is possible, how is it done.

As others have suggested, the only way is with a signed plug-in (applet,
activeX, etc..). It's a security issue on why you (the server) cannot
specify the path and file to download (automatically).

sillyexample.asp
downloadclientpcfile = "C:\theirwordfile_containing_creditcard_info.d oc"
: I strongly suspect it can't be done (at least, not without great
: difficulty) - but if someone can prove me wrong, go right ahead - I
: would thank you for it!

No luck, I can prove it can't be done. Anything for that?

Don
:
:
:
: "John Saunders" <jo***********@surfcontrol.com> wrote in message
: news:%2****************@TK2MSFTNGP09.phx.gbl...
: "Mr Gordonz" <pa**@mobius.net.au> wrote in message
: news:uW**************@TK2MSFTNGP10.phx.gbl...
:: Hi all,
::
:: I want to put a button on a page, and when the user clicks it, the
:: standard Windows "Open File" dialogue box opens, and the user can
:: browse/select a file on their PC. Having selected a file, the user
:: clicks Open, and I then want to capture the file path and name in a
:: string variable. Finally, I want to upload the file to the server.
::
:: BUT: I don't want to use an <input type="file"> control.
:
: Curiosity: why not? You've just described the functionality of <input
: type="file">!
Nov 17 '05 #5

P: n/a
Thanks to all who have responded to my question. It is pretty clear that
using an <input type="file"> control is by far my best option (as I
suspected).

Don - unfortunately, proving me right (ie: it can't be done without great
difficulty) doesn't get you anything, except my thanks for putting the issue
to rest!

Cheers,

MG

"Mr Gordonz" <pa**@mobius.net.au> wrote in message
news:uW**************@TK2MSFTNGP10.phx.gbl...
Hi all,

I want to put a button on a page, and when the user clicks it, the standard
Windows "Open File" dialogue box opens, and the user can browse/select a
file on their PC. Having selected a file, the user clicks Open, and I then
want to capture the file path and name in a string variable. Finally, I
want to upload the file to the server.

BUT: I don't want to use an <input type="file"> control.

Can this be done?

Cheers,

MG

Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.