开发者

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 });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜