您好我正在angularjs中開發web應用程序。我正在開發文件上傳模塊。我有下面的文件詳細信息陣列。如何使用angularjs將文件詳細信息發送到後端?
//下面的代碼來獲得文件
$scope.showPicker=function()
{
var client = filestack.init('AGeDIRvVZTRWgtmFbfGuZz');
client.pick({
}).then(function (result) {
arrMakes.push(result.filesUploaded);
});
}
在上述圖像I中所示我的數組的數組。我有三個文件。 下面是我的角碼發送細節到API。
var files = new FormData();
angular.forEach(arrMakes, function (value, index) {
console.log(value,index);
files.append(index, value);
files.append('data', angular.toJson(index).replace(/['"]+/g, ''));
});
return $http.post(this.uploadUrl, files, {
transformRequest: angular.identity,
headers: {
'Content-Type': undefined,
}
})
問題是我沒有收到服務器端的文件。下面的行給我在服務器中的0個文件。
System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;
我可以知道我是否向服務器發送了正確的數據?有人可以幫我解決這個問題嗎?任何幫助將不勝感激。謝謝。
你的表單數據聲明在哪裏? – Vivz
var files = new FormData();我忘了發佈。 –
請問我可以舉一些例子! –