我正在使用 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"];
但这不起作用。
最佳答案
没有 channel 选项,您无法添加不存在的选项。
要将值传递到服务器,您必须使用 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"]
获取chanel 参数
关于javascript - 在php中获取FileTransfer上传选项变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31348531/