我想使用angular将文件名和文件路径发送到php服务器。 我的代码如下:
T <- 4*10^(5) # data size
x <- c(0, 5, 10, 50, 500, 5000, 50000, 300000) #seed vector
t <- c(290205, 100000, 8000, 1600, 160, 32, 2, 1) #frequency
A <- matrix(0, 4000, 100) #4000 groups
k <- rep(0, times = 8) #record the number of seeds
for(m in 1:4000) {
p <- (t - k)/(T - 100*(m - 1)) #seed probability
A[, m] <- sample(x, 100, replace = TRUE, prob = p) #group m
sm <- 0
i <- 0
for(j in 1:92) {
if(sum(A[m,j:j + 8])==0){
if(A[m,j] > 0 & A[m,j] < 500) {i <- i+1}
sm <- sm+A[100*m+j]
}
else j <- 0
}
if (sm >= 150 & i > 24 & i < 30 & j != 0) {
m <- m + 1
for (n in seq_len(x)) {
k[n] <- sum(A[, m+1] == x[n]) + k[n]
}
}
}
在 $http({
method: 'POST',
url: 'sample.php',
data: "files=" + $scope.files,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data) {
$scope.data = data;
});
};
中存储了我的文件名称,例如
FILE1.TXT,
FILE2.TXT,
file3.txt
我想发送另一个参数$scope.files
,其中将文件路径存储在服务器上,例如
文件/ TEXTFILES /.
答案 0 :(得分:1)
看看是否有效,
$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;
});