I have a Jquery element of input type='file'
.
$('#test').prop('files')[0];
I'd like to change the #test to a string.
var all_data = new FormData();
$('input[type="file"]').each(function(index) {
var i = index+1;
var input_name = '#test'+i;
var file_data = $(input_name).prop('files')[0]; //I think error start here
alert(file_data);
all_data.append('file', file_data);
});
alert(all_data);
But, it's not working.
HTML in PHP script:
$jml = 3;
for($i=1;$i<=$jml;$i++){
echo "<input type='file' name='test".$i."' id='test".$i."'
}