doulanyan6455 2014-11-25 20:57
浏览 198
已采纳

即使下载链接重定向到另一个,也要设置下载文件的名称

I have a page http://example.com/1.html and on it I have a link http://example.com/1.mp4

<a href="http://example.com/1.mp4">Download</a>

which redirect to another link https://example.com/videoplayback?.... which plays the .mp4 file. In order to download the file without redirect I use the download attribute

<a href="http://example.com/1.mp4" download>Download</a>

and in order to set a name to the file I set a value to the download attribute

<a href="http://example.com/1.mp4" download="S1E1.mp4">Download</a>

Now when I click the link the file should start downloading with the name S1E1.mp4 but because the link redirect to another link the file name is "videoplayback". So how can I set the name of this file to be "S1E1.mp4". Thanks for everything. If my question is not clear leave a comment and I'll edit it.

  • 写回答

1条回答 默认 最新

  • dongpu5874 2014-11-25 21:08
    关注

    The real Question is: Why do you redirect? I guess you're using htaccess? Then use a normal rewrite, not a redirect.

    Edit:

    Your PHP-Script should at least provide a Filename per header:

    header('Content-type: -whatever type this is-');
    header('Content-Disposition: attachment; filename="My-Super-Video.mp4"');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器