FileTransfer : POST params with array Key -> value


I would like to use FileTransfer to transfert a file with POST params. if i wirte

var params = {};
params.value1 = 'test';

It’s work fine, but when i write :

var params {arrayValue : ''};
params.arrayValue = {value1: 'test', value2: 'test'};

It does’nt work. I can’t access to arrayValue…

Can you help me ?

Thank You

do you mean:

var params = {
  arrayValue: ''

btw {} = Object and [] = Array implicit an array is also an object… but to be clear Object = {key: value}, Array = [value, value2]

1 Like

Yeah but i would like an array with key / value and this value is an another array key / value.

Thank you very much

you have to set something like that:

var params {
  myArrayParam: ['1', '2', '3']
// console.log(params.myArrayParams[0]);

Thank you

It’s not possible to make something like this ?
var params = {
data : {
title : ‘test’

yeah but than it is not an array :wink: it is an object:

var params = {
  firstName: 'Hans',
  lastName: 'Wurst'

Thank you ^^ but it’s another issuer . i’ve a back end in PHP, and when i post my data, i’ve got an Object like this :
var object = { data : { title : ‘value’, categorie: ‘value2’, … }}; when i make an object like this, it doesn’t work …, but whien i make a basic, it’s work.

Thank you for your help

maybe your PHP backend is not configured to handle JSON request body data per default.
AngularJS is sending the data in contentype application/json

1 Like

I make this :

var params = {};
params.value1 = JSON.stringify({title: 'title'});

And it works fine :slight_smile: thank you very much

I would not make this on clientside. You can simple parse json data in your php-backend