-3

I have a form upload file from computer. My step to upload

1, Click to button

2, After click will run ajax to load the field from server.

3, After loaded that field, I append it to own form. And trigger click it hope a window upload will show. But it does not work. I using jquery 2.1.0

$('.form-file').click();

It already and show by console.log

1 Answers1

0

index.html

<form action="" method="post">
  <div id="upload">Upload</div>
  <div id="file_wrapper"></div>
</form>

form.js

$(document).ready(function(){
  $('#upload').click(function(){
    $('#file_wrapper').load('/element.html', function(){
      $('#file').trigger('click');
    });
  });
})

element.html

<input id="file" type="file" name="file"/>