jquery set value from input type file multifile to

2019-08-15 09:30发布

<form id="myForm" enctype="multipart/form-data" method="POST" 
                                     onSubmit="return form_submit();">
   <input type="file"  name="myfile" id="myfile_main" />

</Form>

Javascript

$("#file_change").change(function(){

    var file=this.files;

    var obj=$.parseJSON(file);

    alert(JSON.stringify(this.files));

});

I am trying to set values from file multifile input (file_change) to a single file (myfile),

my main motive is to select multiple file and upload one by one by self.

I am getting error while setting the each value from multifile input to single file input.

I had tried $.each but not getting any idea about how to set the value in input type file (myfile).

标签: jquery set
1条回答
够拽才男人
2楼-- · 2019-08-15 10:17

It is not possible to programatically select files into a an <input type="file" />. The reason for this is security. Consider if it was possible - it would mean that unscrupulous developers could essentially steal files from visitors computers by using Javascript to select a file and submit the form without the user knowing.

查看更多
登录 后发表回答