0
로컬 컴퓨터에있는 파일을 다운로드하고 싶습니다. 나는 다운로드 링크를 클릭하고 때마다 안전하지 않은 것으로 브라우저에서 URL을주고 : http://localhost:8080/MYOB_Fabric/%7B%7Bangularjs에서 파일을 다운로드 할 수 없습니다.
HTML 코드 :
<div ng-controller="MainCtrl">
<table class="table2" border=1 frame=void rules=rows>
<tr>
<th colspan=3>Transaction Details</th>
</tr>
<tr>
<th>Hash</th>
</tr>
<tr ng-repeat="transaction in transactionDetails ">
<td><a ng-href={{ fileUrl }} download="logFile.txt">{{ transaction.Hash }}</a></td>
</tr>
</table>
</div>
JS 코드 :
var appHlVl = angular.module('hlfabric', [ 'ngRoute' ]);
appHlVl.config(['$compileProvider', function($compileProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(|blob|):/);
}]);
appHlVl.controller('MainCtrl', function($scope, $rootScope,$http,$window,$sce) {
var txtfileURL = '/home/rajasekhar/peer-log.txt';
$http.get(txtfileURL, { responseType: 'arraybuffer' })
.then(function success(response) {
var file = new Blob([response.data], {
type: 'text/plain'
}),
url = $window.URL || $window.webkitURL;
$scope.fileUrl = $sce.trustAsResourceUrl(url.createObjectURL(file));
});
});
대상을 시도 = "_ 빈"은 다음 탭을 열 것입니다, 당신은 내가 "대상"속성으로 문제를 직면하고 있지 않다 = "_ 자기"그것을 열 것 같은 페이지 –
목표를했습니다. 로컬 파일을 다운로드 할 수 없습니다. –
fileurl에 localfile의 경로가 포함되어 있지 않습니다. fileurl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS7VE_YDzLkWX504oXOjLdZwqeatfr7654-kRfG_zyh2_n6GPZvtG9fC82z" –