【问题标题】:How to download a file that has no extension in url? or bypass download prompt?如何下载 url 中没有扩展名的文件?或绕过下载提示?
【发布时间】:2021-03-13 22:56:53
【问题描述】:

单击以下链接时会生成一个文件,并提示我下载并将其保存到我的计算机https://www.bmv.com.mx/es/Grupo_BMV/Informacion_de_emisora/_rid/541/_mto/3/_mod/doDownload?idTipoMercado=CGEN_GLOB&idTipoInstrumento=CGEN_ELGA&idTipoEmpresa=&idSector=&idSubsector=&idRamo=&idSubramo=&random=9493

我正在尝试创建一个自动将此文件下载到服务器的网页,但问题是每当我点击该链接时,我都会收到将其下载到我的计算机的提示。

我试过了

<a href='<?php echo "$urlAc";?>' download>Actualizar Acciones globales</a>

但我相信只有当那是文件的 URL 时才有效。

我也尝试过,但没有积极的结果

echo file_put_contents($file, fopen($urlAc, 'r'));

有没有其他方法可以直接生成文件并将其下载到我的服务器?

【问题讨论】:

  • “我也尝试过,但没有积极的结果” ????你得到了什么结果?
  • 一个非常难看的二进制文件,看起来像这样:\D0\CFࡱ\E1\00\00\00\00\00\00\00\00\00\00\00\00\ 00\00 等等。感谢您的评论,我意识到这就是我想要的文件

标签: javascript html url curl php-7


【解决方案1】:

感谢 Phil,我意识到 file_put_contents($file, fopen($urlAc, 'r')); 工作正常。我将文件下载为“sample.txt”,然后将其重命名为“sample.xls”,效果很好!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-24
    • 2013-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-06
    相关资源
    最近更新 更多