Professional Web Applications Themes

Button to launch "Open File" Dialogue - ASP.NET General

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...

  1. #1

    Default Button to launch "Open File" Dialogue

    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


    Mr Guest

  2. #2

    Default Re: Button to launch "Open File" Dialogue

    "Mr Gordonz" <net.au> wrote in message
    news:phx.gbl... 
    standard 
    then 

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


    John Guest

  3. #3

    Default Re: Button to launch "Open File" Dialogue

    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" <net.au> wrote in message
    news:phx.gbl... 
    standard 
    then 


    Vidar Guest

  4. #4

    Default Re: Button to launch "Open File" Dialogue

    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" <com> wrote in message
    news:%phx.gbl...
    "Mr Gordonz" <net.au> wrote in message
    news:phx.gbl... 
    standard 
    then 

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



    Mr Guest

  5. #5

    Default Re: Button to launch "Open File" Dialogue

    In news:%phx.gbl,
    Mr Gordonz <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" <com> wrote in message
    : news:%phx.gbl...
    : "Mr Gordonz" <net.au> wrote in message
    : news: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">!


    Don Guest

  6. #6

    Default Re: Button to launch "Open File" Dialogue

    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" <net.au> wrote in message
    news: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



    Mr Guest

Similar Threads

  1. How to add "..." button to a property to open up "File Open"?
    By slow learner in forum ASP.NET Building Controls
    Replies: 2
    Last Post: August 26th, 06:29 AM
  2. Replies: 0
    Last Post: September 22nd, 03:31 AM
  3. Unable To Open File "..." Because It Is Already Open With Write Permission
    By PixelaseR webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 1
    Last Post: August 18th, 06:33 PM
  4. Button to launch the "File Open" dialog
    By Eric Newton in forum ASP.NET Security
    Replies: 0
    Last Post: August 15th, 06:41 PM
  5. Replies: 0
    Last Post: July 11th, 07:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139