在 php 中获取 FileTransfer 上传选项变量

Get FileTransfer upload options variables in php

我正在使用 cordovaFileTransfer 插件。 使用下面的代码,我还将选项变量发送到我的 upload.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 文件中检索 "channel" 值(在选项变量中)。 在我的 php 文件中,我尝试了 $channel = $_POST["channel"]; 但这不起作用。

没有频道选项,不能添加不存在的选项。

要将值传递给服务器,您必须使用参数选项:

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"]

获取香奈儿参数