简体   繁体   English

Polymer:铁表格如何通过文件上传将参数附加到url

[英]Polymer:iron form how to append parameters to url with file upload

i am trying to create a form entry in which user selects certain parameters like date and type of file and he uploads the file and when he click on upload , the parameters should be appended to url, is it possible to send multipart form data this way or do you i have to send it in the body? 我正在尝试创建一个表单条目,其中用户选择某些参数,例如文件的日期和类型,然后他上载该文件,并且当他单击“上载”时,该参数应附加到url,是否可以通过这种方式发送多部分表单数据还是您必须将其发送到体内?

<form id="form" is="iron-form" on-iron-form-presubmit="_presubmit" on-iron-form-response="_handleResponse" method="POST" action="/idp/ui/api/addAsset" keytest="Hello" content-type="multipart/form-data">



  <paper-dropdown-menu on-iron-select="_itemSelected">
  <paper-listbox slot="dropdown-content" selected="0">
   <paper-item>file1</paper-item>
   <paper-item>file2</paper-item>
   <paper-item>file3</paper-item>
   <paper-item>file3</paper-item>


  </paper-listbox>
  </paper-dropdown-menu>

 <paper-input name="AquisitionDate"  label="ACQUISITION DATE *" 
  placeholder="YYYY-MM-DD" always-float-label  error-message="please enter 
  numbers!"></paper-input>

 <paper-input name="filetype" type="file" accept="image/*" required></paper-
 input>


 <div id="container">
 <paper-button on-tap="_submit" raised class="indigo">upload</paper-button>
 </div>
 </form>

i was trying to append parameters in _presubmit function 我试图在_presubmit函数中附加参数

_presubmit:function(){
var body = this.$.form.request.body.AquisitionDate;
this.$.form.action='/idp/ui/api/addAsset'
+'?'+'file='+this.fileName+'&'+'date=+body;
console.log('form url:',this.$.form.action);
console.log(this.fileName+body);
}

but when i am submitting the form only the api is being hit not with parameters, how should i handle file upload in iron form so that i can send input values as parameters in url? 但是,当我提交表单时,仅使用API​​而不使用参数,那么我应该如何处理文件形式的文件上载,以便可以将输入值作为参数发送到url中?

您可以使用以下代码作为示例:

this.$.form.request.params['paramName'] = 'paramValue';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM