【发布时间】:2018-06-28 14:36:12
【问题描述】:
我是 amphtml 的新手。我想在 amp Html 中提交一个表单,在 localhost 中输入 type="file"。我该如何继续?当输入 type="text" 完美运行时。但是在输入中type="文件",会报错。
【问题讨论】:
我是 amphtml 的新手。我想在 amp Html 中提交一个表单,在 localhost 中输入 type="file"。我该如何继续?当输入 type="text" 完美运行时。但是在输入中type="文件",会报错。
【问题讨论】:
我假设您使用的是 method="GET",<input type="file" /> 不适用于 method="get",您必须使用 method="post" 和属性 action-xhr 来代替 action。
For example you can check here
JS 代码
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
HTML 代码:
<form method="post"
action-xhr="where-you-want-submit"
target="_top">
<p>Form Submission with Page Reload</p>
<div class="ampstart-input inline-block relative mb3">
<input type="file" name="any_name">
</div>
<input type="submit"
value="Submit"
class="ampstart-btn caps">
</form>
【讨论】: