Immediately submit upload form after selecting file
In this post, we are going to see how to submit an HTML form with input type file immediately after one select a file. That means when one selects a file it should submit instantly to upload.
It is always the best way to learn from the example. So here we are going to see an example code snippets that will do this task. Before we go forward, suppose we have an HTML form with a file input type that is given below:
<form action="action_page.php" id="upload_form" method="post" enctype="multipart/form-data"> <input type="file" id="myfile" name="myfile"> <input type="submit"> </form>
Now we want the above form with to be submitted instantly when we choose a file from the uploader.
Using jQuery to submit uploader form immediately
This task also can be done by using jQuery. Below is the jQuery code that will do that easily:
So, you have seen how easy it is to submit a form automatically when you select a file through the uploader. I hope you will be helpful and use this knowledge in your work.