1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

Show file after upload and reset input

This commit is contained in:
Kyle Spearrin
2017-07-12 14:17:21 -04:00
parent 842b157955
commit f761733d0b
2 changed files with 27 additions and 14 deletions

View File

@@ -18,7 +18,8 @@
});
$scope.save = function (form) {
var files = document.getElementById('file').files;
var fileEl = document.getElementById('file');
var files = fileEl.files;
if (!files || !files.length) {
validationService.addError(form, 'file', 'Select a file.', true);
return;
@@ -31,9 +32,13 @@
return apiService.ciphers.postAttachment({ id: loginId }, fd).$promise;
}).then(function (response) {
$analytics.eventTrack('Added Attachment');
toastr.success('The attachment has been saved.');
closing = true;
$uibModalInstance.close(true);
$scope.login = cipherService.decryptLogin(response);
// reset file input
// ref: https://stackoverflow.com/a/20552042
fileEl.type = '';
fileEl.type = 'file';
fileEl.value = '';
}, function (err) {
if (err) {
validationService.addError(form, 'file', err, true);