jQuery auto upload file
I want the file input will automatic upload my image without enter any submi开发者_如何转开发t 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
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 });
精彩评论