2

I have two forms, i want to copy the first file input to another one for the servlet to be able to get the parameter.

<form id="UploadExcel" >
              <input id="file" name="file" type="file" />
              <input type="submit" value="upload" />                   
        </form>

            <form action="UploadToDatabase" method="post" enctype="multipart/form-data">
            <div id="table1">
            <!--radio button-->
            </div>
        <input id="submitDatabase"  type="submit" value="Submit" />
            <input id="SheetValue"  name="SheetValue" type="hidden" value="-1" />
            <input id="file1" name="file1" type="hidden" />
             <span style=color:red id="radio_error"></span>
      </form>

i tried to do this but it did not work

 var file = document.getElementsByName('file');
    $('input.file1').val(file);
SCS
  • 1,162
  • 3
  • 17
  • 31

1 Answers1

1

You can't move the value of one file input to another, it is a security risk. Instead, clone the input, place the clone where the original is, and move the original into the hidden form. Refer this

Community
  • 1
  • 1
Neelesh
  • 666
  • 6
  • 17