40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
|
|
var arr = window.location.href.split("/");
|
|
if (arr[3].indexOf('app') == 0)
|
|
baseUrl = '';
|
|
else
|
|
baseUrl = '/' + arr[3];
|
|
angular.module('Utility.UploadFile', [])
|
|
.factory('UploadFile', ['$http', '$timeout', function ($http, $timeout) {
|
|
|
|
this.uploadFile = function (scope, row) {
|
|
var upload = createUploadElement();
|
|
|
|
upload.onchange = function () {
|
|
//console.log($timeout);
|
|
UploadFiles(this.files, scope, row);
|
|
};
|
|
|
|
upload.click();
|
|
};
|
|
|
|
this.downloadFile = function (fileUrl) {
|
|
var downloadLink = document.createElement('a');
|
|
|
|
downloadLink.href = fileUrl;
|
|
downloadLink.click();
|
|
delete downloadLink;
|
|
};
|
|
|
|
return this;
|
|
|
|
function UploadFiles(files, scope, row) {
|
|
uploadFile($http, files[0]).then(function (response) {
|
|
row.ReferenceFileLink =baseUrl+ response.data[0];
|
|
//console.log('UploadFiles', row.ReferenceFileLink);
|
|
}, function (error) {
|
|
console.log(error);
|
|
}).then(function () {
|
|
});
|
|
}
|
|
}]); |