我是amphtml的新手。我想在amp html中提交一个表单,在localhost中输入type =“ file”。如何继续?当输入type =“ text”正常运行时,但在输入中type =“ file”,它会产生错误。
答案 0 :(得分:1)
我假设您正在使用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>