简体   繁体   中英

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?

<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: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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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