Skip to content

Commit 80a7c49

Browse files
author
masdeft
committed
Fix the file uploading
1 parent 6aa8b94 commit 80a7c49

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

client/app/controllers/UploadCtrl.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
var module = angular.module('myCloudDriveApp');
55

6-
function UploadCtrl($document, $scope, FileManager) {
6+
function UploadCtrl($document, $state, $scope, upload, FileManager) {
77
$scope.close = function() {
88
var modalHtmlElement = angular.element($document[0].getElementById('modal')),
99
modalOverlayHtmlElement = angular.element($document[0].getElementById('modal-overlay'));
@@ -12,11 +12,20 @@
1212
close(modalOverlayHtmlElement);
1313
};
1414

15-
$scope.upload = function(files) {
16-
var formData = new FormData();
17-
formData.append('file', files[0]);
15+
function successHandler(response) {
16+
$state.reload($state.current);
17+
}
1818

19-
FileManager.upload(formData);
19+
$scope.upload = function(files) {
20+
upload({
21+
url: FileManager.upload.path,
22+
method: FileManager.upload.method,
23+
data: {
24+
filePath: files[0].name,
25+
26+
file: files[0]
27+
}
28+
}).then(successHandler);
2029
};
2130

2231
function close(element) {

client/app/directives/upload.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
$scope.upload(event.target.files);
1818
// Close the modal box
1919
$scope.close();
20-
21-
$state.reload($state.current);
2220
});
2321
}
2422
};

0 commit comments

Comments
 (0)