[英]Polymer iron-form multipart/form-data support
I'm trying to get image submission working inside an iron-form
and am running into some difficulties. 我正在尝试使图像提交工作在iron-form
并且遇到一些困难。 Here's a minimized version of the form: 这是表格的最小化版本:
<dom-module id="file-upload">
<template>
<form is="iron-form" id="form" content-type="multipart/form-data" action="http://localhost:9090/upload" method="post">
<input name="field-1" type="file" accept="image/*" required><br>
<paper-button on-tap="submit">submit</paper-button>
</form>
</template>
</dom-module>
<script>
Polymer({
is: "file-upload",
submit: function() {
this.$.form.submit();
}
});
</script>
When I try to send the file over to my Go server, I get this error: 当我尝试将文件发送到Go服务器时,出现以下错误:
no multipart boundary param in Content-Type
I already got a regular form working properly, so I know it isn't an issue with my server, but I want to use all of the fancy Polymer elements for other fields that will be added to the form. 我已经有一个正常的表格,可以正常工作,所以我知道这不是服务器的问题,但我想将所有精美的Polymer元素用于将添加到表格中的其他字段。 Is anyone aware if multipart/form-data
is currently unsupported as a content-type? 有人知道当前是否不支持multipart/form-data
作为内容类型吗?
I could create a regular form which contains Polymer elements which bind to hidden inputs, but it seems like a gross hack that I'd like to avoid if possible. 我可以创建一个常规表单,其中包含绑定到隐藏输入的Polymer元素,但如果可能的话,我想避免这种粗暴的行为。
Try with this element: ajax-file-input 尝试使用此元素: ajax-file-input
It works for me, for PHP backend $_FILES is containing the upload data. 它对我有用,对于PHP后端$ _FILES包含上传数据。
Apparently unsupported. 显然不受支持。 There was an open issue about this a couple of years ago, with some suggestions on how to work around here: https://github.com/PolymerElements/iron-form/issues/54#issuecomment-156966362 几年前,有一个关于此问题的公开问题,并提出了一些有关如何在此处解决的建议: https : //github.com/PolymerElements/iron-form/issues/54#issuecomment-156966362
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.