2015-07-10 55 views
1

我正在使用cordovaFileTransfer插件。 下面的代碼,我也發送選項變量到我的upload.php文件。獲取FileTransfer上傳選項變量在php中

var options = { 
    fileKey: "file", 
    channel: $scope.channel, 
    fileName: $scope.filename , 
    chunkedMode: false, 
    mimeType: "image/jpg" 
}; 

$cordovaFileTransfer.upload(server, filePath, options).then(function(result) { 
... 

如何從我的php文件中檢索「通道」值(在選項變量中)。 在我的php文件中,我嘗試了$channel = $_POST["channel"];,但這不起作用。

回答

2

沒有頻道選項,您不能添加不存在的選項。

值傳遞給你不得不使用params選項服務器:

var parameters = {}; 
parameters.channel = $scope.channel; 

var options = { 
    fileKey: "file", 
    channel: $scope.channel, 
    fileName: $scope.filename , 
    chunkedMode: false, 
    mimeType: "image/jpg", 
    params : parameters 
}; 

現在,你應該能夠$_POST["channel"]

+1

PARAMS獲得香奈兒PARAM:參數 –

+0

是啊,謝謝!編輯 – jcesarmobile