1

<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).

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.