problem with reset/clear in <input type="file" >

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default problem with reset/clear in <input type="file" >

    how to clear values in input file object.
    In My Form i need to upload a file and enter some values in other text fields.
    i have "Submit" and "Clear".
    i f i click clear button i need to call a javascript function and clear all
    fields.
    I am able to clear all fields by setting "" to each field object.

    Where as for object <input type="file" > i could not clear value in it.

    my code is as below
    Can any one help me??

    ------------
    <script>
    fnClear(){
    document.forms[0].txtAttachment.value = "";
    }
    </script>
    <html>
    <form>
    <input type="file" name="txtAttachment" size="50" maxlength="100"
    id="txtAttachment" >

    123nani123 Guest

  2. Similar Questions and Discussions

    1. html <input type="file"> can you set a value first ?
      There has GOT to be a way. I'm not gonna give up.
    2. Help please: Exception when with <input type="file"> but not with Textbox
      I've encounted a pretty strange problem and I'm not quite sure what to make of it. I have a web service that consumes an XML file as well as a...
    3. <input type="image"... based custom control
      I have created one of these controls but arent getting any call backs. I've got the source from the MSPress book "Developing Microsoft ASP.NET...
    4. HTML + <input type="File">
      Hi I'm trying to set default value for input type file. <input type="File" name="tx_pdffile" accept="*.pdf" class="boxText" value="abc.pdf"> ...
    5. <input type="file"> readonly
      Just reading from a previous thread about multiple uploads. I wanted to use script to create multiple input file elements that put the path in as...
  3. #2

    Default Re: problem with reset/clear in <input type="file" >

    The answer is simples: the input[type='file'] don't have the "value"
    propertie. It's a security question... Realize that you enter a site
    and this site has a input[type='file'] in a hidden (position:
    absolute; top: -10000;). In the case of you could change the "value"
    property for a input[type='file'], you would be able to get files from
    the guest's PC without his permission. You would be able to change the
    "value" to any value and, if the path you set (i.e.:
    c:\windows\php.ini) exists in the guest's PC, the file would be sent
    to the server. Got it?
    You can do a simple "document.forms['formname'].reset()" to solve
    your problem.

    []s

    --
    ~~ ~
    diego nunes
    web engineer
    ~ ~~


    Diego Nunes Guest

Posting Permissions

  • You may not post new threads
  • You may 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