我想使用angular将文件名和文件路径发送到php服务器。我的代码如下所示:
$http({
method: 'POST',
url: 'sample.php',
data: "files=" + $scope.files,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data) {
$scope.data = data;
});
};
在$scope.files
其中存储了我的文件的名称,例如
file1.txt,
file2.txt,
file3.txt
我想发送另一个参数($scope.source)
存储在服务器上的文件路径例如
文件/文本文件/。
看看是否可行,
$http({
method: 'POST',
url: 'sample.php',
data: {
"files": $scope.files,
"source": 'files/textfiles/'
},
transformRequest: function (obj) {
var str = [];
for (var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data) {
$scope.data = data;
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句