【发布时间】:2016-04-20 04:27:41
【问题描述】:
您好,我有他的上传文件表格
$("#form").on('submit',(function(e) {
e .preventDefault();
$.ajax({
url: "index2.php",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
...
在 HTML 格式中:
<form id="form" action="index2.php" method="post" enctype="multipart/form-data">
<input id="uploadImage" type="file" accept="image/*" name="image" /><br/>
<input id="button" type="submit" value="Upload">
</form>
它有效。但现在我想要删除按钮。我想在选择文件时自动上传。
$.ajax({
url: "index2.php",
type: "POST",
data: new FormData("#form"),
contentType: false,
...
但不起作用。可以帮我做吗?
【问题讨论】:
-
您需要等到文件完成上传。有什么尝试?
-
好的,我不想提交然后开始上传,我想从本地主机选择文件时,立即开始上传文件
标签: javascript jquery forms form-data