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 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?