如何在不打开预览的情况下从URL下载文件

发布于 2025-02-11 03:45:11 字数 911 浏览 0 评论 0原文

到目前为止,我已经看到了很多问题,这些问题被提出了,但在我的情况下没有任何作品。

我想首先告诉你服务器端不是我的!表示URL是 从另一个来源!

我尝试的是 -


我尝试在锚标签或< a href =“ urlhere”下载 attr只需打开一个带有预览的新页面 还尝试使用React 链接它们都没有使用!


并尝试使用这些库 file-saver js-file-downloader,, 同样的问题!


在尝试其中一件事时,我会出现错误的说法 -

Access to XMLHttpRequest at 'urlOfDownloadingfile' from origin 'http://localhost:3000'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
header is present on the requested resource. 

我认为,因为服务器端不受我控制,所以这就是为什么它正在发生!

有什么办法可以解决这个问题!

任何帮助将永远不感激!

So far I have already seen a lot of questions where this type of question were asked but none of works in my case.

I would like to tell you in the first place is The Server Side is Not Mine! means the URL were
from another source!

What I've tried is -


I have tried to add download attr in the anchor tag or <a href="urlhere" download></a> It will just open a new page with preview
also tried with react Link none of them worked!


And tried with these libraries file-saver, js-file-downloader,
same issues!


when trying one of those things I got an error saying -

Access to XMLHttpRequest at 'urlOfDownloadingfile' from origin 'http://localhost:3000'
has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
header is present on the requested resource. 

I think because the server-side is not controlled by me so that's why it is happening!

Is there any way I can solve this issue!

Any help will be always appreciated!

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

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

发布评论

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