【发布时间】:2017-09-29 07:30:19
【问题描述】:
我正在尝试下载位于我的本地计算机中的具有特定路径的文件。
我做了以下代码,下载了 html5 方法和 ng-href:
<file-download fileurl="{{ Pathfile }}" linktext="Click to download"></file-download>
myApp.directive('fileDownload', function(){
return {
restrict: 'E',
scope: {
fileurl: '@fileurl',
linktext: '@linktext'
},
template: '<a href="{{ fileurl }}" download>{{ linktext }}</a>',
link: function(scope, elem, attrs) {
}
}
});
我尝试使用以下配置,但我在 url 中添加了相同的不安全
myApp.config( [
'$compileProvider',
function( $compileProvider )
{
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|file|blob|ftp|mailto|chrome-extension):/);
}
]);
我的下载网址总是不安全。如何解决?
【问题讨论】:
-
您无法访问除服务器提供的任何文件
-
如果我认为我的本地机器是服务器,也许还有另一种方法?
标签: angularjs