0
我想嚴格遵守使用$ http或$資源做文件上傳的angularjs代碼。
var uploadData = new FormData();
uploadData.append('file', obj.lfFile);
var fileData = angular.toJson({
'FileName': obj.lfFile.name,
'FileSize': obj.lfFile.size
});
uploadData.append('fileData', fileData)
$http({
method: 'POST',
url: vm.uploadPath,
headers: {
'Content-Type': undefined,
'UserID': vm.folder.UserID,
'ComputerID': vm.folder.ComputerID,
'KeepCopyInCloud': vm.keepCopyInCloud,
'OverWriteExistingFile': vm.overwriteExistingFile,
'RootFileID': vm.folder.RootFileID,
'FileName': obj.lfFile.name,
'FileSize': obj.lfFile.size
},
eventHandlers: {
progress: function(c) {
console.log('Progress -> ' + c);
console.log(c);
}
},
uploadEventHandlers: {
progress: function(e) {
console.log('UploadProgress -> ' + e);
console.log(e);
}
},
data: uploadData,
transformRequest: angular.identity
}).success(function(data) {
console.log(data);
}).error(function(data, status) {
console.log(data);
console.log(status);
});
事件並沒有被解僱。我錯過了什麼?
參考