从 HTTPS 站点下载 HTTP 文件

发布于 2025-01-15 11:55:48 字数 696 浏览 2 评论 0原文

我正在尝试从未安装 SSL 证书 (HTTP) 的远程资源获取文件。用户单击按钮后,它会将一些数据发送到服务器上的 PHP 文件,该文件执行一些操作以创建指向外部资源的链接: http://givememystuff.com/1/2/3/ABCS

然后脚本将链接传递回客户端(JavaScript 和 jQuery),以便客户端下载文件。我最近的尝试是使用下面的代码,该代码在 Chrome 中效果很好。问题是,当它在 Edge 中运行时,MS 会阻止下载,因为它来自 HTTP 位置。

对我哪里出错有什么想法吗?

complete: function(xhr) {
            if(xhr.status == 200) {
                var data = xhr.responseText;
                // console.log(data);
                
                window.open(data);
            } else {
                console.log(xhr);
                alert("Unable to pull Document");
            }

I am attempting to get a file from a remote resource that does not have an SSL Certificate installed (HTTP). Once the user clicks the button, it sends some data to a PHP file on the server which performs some manipulation to create a link to the external resource: http://givememystuff.com/1/2/3/ABCS

The script then passes the link back to the client (JavaScript with jQuery) for the client to download the file. My latested attempt at getting this to work is using the code below which works great in Chrome. The issue is when this runs in Edge, MS blocks the download because it comes from an HTTP location.

Any thoughts on where I am going wrong?

complete: function(xhr) {
            if(xhr.status == 200) {
                var data = xhr.responseText;
                // console.log(data);
                
                window.open(data);
            } else {
                console.log(xhr);
                alert("Unable to pull Document");
            }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文