如何在不打开预览的情况下从URL下载文件
到目前为止,我已经看到了很多问题,这些问题被提出了,但在我的情况下没有任何作品。
我想首先告诉你服务器端不是我的!表示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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论