我可以获取我请求的文件的原始数据,但无法让浏览器向用户提供文件。我需要使用 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
我在服务文件中使用了下面的代码来下载项目,效果很好。我从那里得到的http://filamentgroup.com/lab/jquery_plugin_for_requesting_ajax_like_file_downloads/
$('<form action="'+ url +'" method="'+ ('post') +'">'+inputs+'</form>')
.appendTo('body').submit().remove();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)