I would like to send filenames and filepath to php server using angular. My code looks like:
$http({
method: 'POST',
url: 'sample.php',
data: "files=" + $scope.files,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data) {
$scope.data = data;
});
};
In $scope.files
are stored the names of my files eg
file1.txt,
file2.txt,
file3.txt
and I would like to send another parameter ($scope.source)
where is stored filepath on server eg
files/textfiles/.
See if this works,
$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;
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.