Use multiple selection in the array and upload to the server


#1

I am stuck in making the selection of a multiform data array, with multiple images

I uses PhantomJS to do this. The upload works fine with a single image

the html array looks like this

    <div><input name="attachment[]" type="file"></div>
    <div><input name="attachment[]" type="file"></div>
    <div><input name="attachment[]" type="file"></div>

I am using the below code to populate the arrays of file types

page.uploadFile('input[type=file]', 'test2.png');  
page.uploadFile('input[type=file]', 'test3.png');

However after the execution, only test3.png is loaded in the html - Page render gave the below image

https://i.stack.imgur.com/qsKaE.png

How can i modify the code to make it as a multiple selection? Should include test2.png as well.
How can i modify so that the filename is a variable? instead of hardcosing ‘test2.png’, I need to make it as a variable.