I want the file input will automatic upload my image without enter any submit button.
<form action="/upload/" method="post" enctype="multipart/form-data">
<input type="hidden" name="user_id" value="47" />
<input type="file" name="upload" />
</form>
Let me know the trick with jQuery
The <input type="file"> defines a file-select field and a "Browse" button for file uploads. To define a file-select field that allows multiple files to be selected, add the multiple attribute. Tip: Always add the <label> tag for best accessibility practices!
jQuery Events Save the scripts. js file, and refresh index. html in the browser.
You can submit the form on the file input's onchange event, like this:
$("input[name=upload]").change(function() {
$(this).closest("form").submit();
});
With more recent versions you can also just set the autoUpload option to true:
$('#fileupload').fileupload({ autoUpload: true });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With