Button to launch "Open File" Dialogue

M

Mr Gordonz

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
 
J

John Saunders

Mr Gordonz said:
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">!
 
V

Vidar Petursson

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
==============================
 
M

Mr Gordonz

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



Mr Gordonz said:
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">!
 
D

Don Verhagen

In Mr Gordonz <[email protected]> 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.doc"


: 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


:
:
:
: : :: 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">!
 
M

Mr Gordonz

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



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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top