样式输入文件和自动提交 [英] Style input file and auto submit

查看:130
本文介绍了样式输入文件和自动提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个单一的文字链接,用户点击,并询问用户他/她想要上传的文件,然后,自动将其自动发送到表单。我该如何实现呢?我知道我必须对文件输入进行风格化,但是如何在文件选择时自动发布文件?

I am trying to have a single text link on which the user clicks and it asks the user which file he/she wants to upload then, auto matically POSTs it to the form. How can I achieve the same? I know I have to style my file input but how to get it to post automatically on file selection?

非常感谢

推荐答案

您可以调用表单的submit方法。它会将您的页面提交到服务器,您可以在请求的文件集合中获取该文件。

You can call the submit method of your form. It will submit your page to the server and you can get the file in the Files collection of the request.

您必须调用submit

You'll have to call the submit() method of the form on the "onchange" event of the "file" element.

<input type="file" onchange="formname.submit();" id="f" />

编辑:尝试此操作

这篇关于样式输入文件和自动提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆