CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2000
    Location
    MN
    Posts
    8

    Fill Input File Type box on a web page

    I am trying to automate filling a form on the Web.
    I have a file type input box and how can I put values on that Text box? I was able to put values into common text boxes other than type "File".
    Anybody has any ideas???

    Here is a sample htm file which has a file input box.

    Test.htm
    --------
    <p align=left>Enter name of TEXT file:<input id="file1" name="txtFile" type="file" ></p>
    </p>



  2. #2
    Join Date
    Sep 2000
    Location
    Ottawa, Ontario
    Posts
    356

    Re: Fill Input File Type box on a web page

    This cannot be done because the file type text box is client side and you have no control of the value. I tried for fun using this to test it. you can set smelly input box but not the file one.

    <body>
    <form name="filer">
    <p align="left"> Enter name of TEXT file:<input id="file1" name="txtFile" type="file"></p>
    <P>Yoshi <input id="txtoknow" name="smelly"></P>
    </form>
    </body>
    <script Langauge=javascript>
    window.onload = document.forms[0].smelly.value = "C:\\test.txt"
    </script>


  3. #3
    Join Date
    Jun 2001
    Posts
    1

    Re: Fill Input File Type box on a web page

    Did you ever find a solution to this problem?

    I am also trying to pre-fill a form (on the client side). I can use the DOM to get input elements and set their value (xx.value = "abc"). This works for input type = text, and input type=password. However, it does not work for input type=file.

    Any clues?


  4. #4
    Join Date
    Oct 2000
    Location
    MN
    Posts
    8

    Re: Fill Input File Type box on a web page

    Yes, I did.
    I had to use a third party control to do this.
    The control CSINet is available at
    http://web.singnet.com.sg/~kegoh/CSInet.htm.
    Try it out..
    Here is an example of code.
    CSControl1.URL = "http://localhost/abc.htm"
    CSControl1.clearfile
    CSControl1.Addfile "txtfile", "C:\a.txt"
    CSControl1.abort
    strRes = CSControl1.Upload

    Makesure that URL property for the CSInet should be the page which you are trying to post.





Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured