Josh Foskett
Josh Foskett

Reputation: 4121

Send params to remote server with FileTransfer() using PhoneGap?

So I'm creating an iOS app using PhoneGap, and I need to send extra params to the remote server containing the users id, secret hash, etc with FileTransfer().

From the PhoneGap example on FileTransfer(), I see that you can set params, but are they also sent to the remote server? If so, are they sent as $_POST or $_GET variables? If not, is there a way for me to send params to my remote server with FileTransfer()?

var params = new Object();
params.value1 = 'test';
params.value2 = 'param';

options.params = params;

var ft = new FileTransfer();
ft.upload(imgURI, 'http://example.com/upload', win, fail, options);

Upvotes: 2

Views: 6005

Answers (1)

Josh Foskett
Josh Foskett

Reputation: 4121

The paramaters are in fact sent as POST variables with FileTransfer().

For example, when I console.log the response from FileTransfer(), I get the following:

array(2) {
  ["value1"]=>
  string(4) "test"
  ["value2"]=>
  string(5) "param"
}

On my remote server, I used the following PHP code:

<?php

var_dump($_POST);

Upvotes: 5

Related Questions