duanhuizhe6767 2009-02-12 13:41
浏览 32
已采纳

当用户下载它时,在另一台服务器上重命名文件[2] - 使用PHP

I have asked this question today already but this time I want to know if I can achieve this via PHP since Javascript wasn't up to it.

I have a link to a file on another server. If i provide this link to my users the headers are pushed out to download that file from that server.

Is there a way for me to capture those headers and file and redirect the download to the user? I would like to do this so that I can change the filename of the download since it is always 'file.zip'.

Is this possible with PHP?

Thank you for any help.

  • 写回答

3条回答 默认 最新

  • doumianfeng6979 2009-02-12 13:48
    关注

    You could do this, and you can do it in several ways.

    1) (simple) copy the file to your server, and rename it. Point your download links to this copy.
    2) (harder) Create a stub php file, called , read the file from the remote server within php, and stream the content to the script output. This will need you to set appropriate headers, etc. as well as setting up your webserver to parse through PHP.

    Seriously, I'd go with option 1. (assumes you have a legal right to serve the content, etc.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题