The*_*ink 5 download express angularjs
我可以获取我请求的文件的原始数据,但是我无法让浏览器向用户提供文件.我需要使用iframe吗?
//Client code
download_file: function (path, callback) {
$http.post('/download/client_file', {path:path}).
success(function(data, status, headers, config) {
console.log(data); //this contains the raw data of the res.download
//from the server.
});
}
//server code
res.download(file); // the path is proper
Run Code Online (Sandbox Code Playgroud)
我在服务文件中使用下面的代码来下载项目,效果很好。我从http://filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads/得到它
$('<form action="'+ url +'" method="'+ ('post') +'">'+inputs+'</form>')
.appendTo('body').submit().remove();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1649 次 |
| 最近记录: |