仅将更改时的文件输入提交到服务器并忽略其他输入,直到按下提交表单
我有一个这样的表单
<form method="post" action="">
<input type="text" onchange="uploadFile()" name="username">
<textarea name="description"></textarea>
<input type="file" name="upload">
<button>Submit</button>
</form>
,我希望当用户选择文件
时自动上传
文件,而不是当用户单击提交
按钮时
尝试在更改事件上上传此文件确实会显示发布请求,但文件不在请求中。
问题: 是否可以通过 ajax 将单个输入提交到服务器而不包含其他字段?
I have a form like this
<form method="post" action="">
<input type="text" onchange="uploadFile()" name="username">
<textarea name="description"></textarea>
<input type="file" name="upload">
<button>Submit</button>
</form>
I want when a user selects a file
to automatically upload
the file instead of the when the user clicks the submit
button
trying to upload this on change event does show a post request, but the files are not in the request.
Question:
Can an individual input be submitted to the server without the other field inclusion via ajax?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这应该是可能的。
下面是一个示例:
其他修复:
Yes, It should be possible.
Heres an example:
Other fixes: