2

Used Uppy XHR Upload. Docs: https://uppy.io/docs/xhr-upload/ How to add custom post fields in Uppy XHR request?

My params are:

endpoint: '/?test1=test2',
formData: true,
method: 'post',
fieldName: 'files[]',
// metaFields: [{ cmd: 'test1', name2: 'test2' }],
metaFields: [
  ['command', 'myvalue']
]

It is need to add my additional "post" fields for server, but test1=test2 are "get" params, 'command' and 'myvalue' - params without values (only keys are send via XHR). How to add "post" params and it`s values in Uppy XHR (or other uppy plugins, if in XHR not available)?

Anton
  • 59
  • 6

2 Answers2

2

You should use meta in Uppy.Core to pass post parameters with values. Eg:

Uppy.Core({

        meta: {
            professional_id: professional_id,
            client_id: client_id,
            post_id: post_id,
            proposal_id: proposal_id,
            folder_id: folder_id,
            version_no: version_no
        },
0

An alternate syntax would be:

 uppy.setMeta({content_type:2})
 uppy.use(Uppy.XHRUpload, { endpoint: 'document_uppy.cfm'
    ,id:'xhrupload_doc'
     ,bundle:false })

Please ensure you have set bundle to false

Yoosaf Abdulla
  • 3,722
  • 4
  • 31
  • 34