编辑文件下载信息 PHP/JS
嘿,我正在尝试更改通过我的网站从外部服务器下载的文件的名称。
目前,每当我修改标头信息时,都需要很长时间才能开始下载,那么有什么方法可以在不更改标头的情况下完成下载呢?或者,如果没有任何原因,为什么要花很长时间才能加载我的标头?
这就是我正在做的事情,
@header("Cache-Control: no-cache, must-revalidate");
@header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
@header("Content-Length: ".getfilesize($url));
@header("Content-Disposition: attachment; filename=".$name);
@header("Content-type: audio/mpeg;\r\n");
die(@readfile($url));
可以用 javascript 或其他东西来代替吗?我可以让所有下载开始而无需在 Windows Media Player、QuickTime 等中打开吗?
谢谢:)
Hey, I'm trying to change the name of a file being downloaded through my site off an external server.
Currently whenever I modify the header information, it just takes a reallllllyyyyyy long time for the download to start, so is there any way to do it without changing the headers? Or if not any reason why it would be taking forever to load with my headers?
This is what I'm doing
@header("Cache-Control: no-cache, must-revalidate");
@header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
@header("Content-Length: ".getfilesize($url));
@header("Content-Disposition: attachment; filename=".$name);
@header("Content-type: audio/mpeg;\r\n");
die(@readfile($url));
Could it be done in javascript or something instead? And could i make it so all downloads start without opening in like windows media player, quicktime etc.
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这需要“非常长的时间”,因为您首先将文件加载到服务器,然后每次有人单击下载链接时将其发送到客户端。
It takes a "reallllllyyyyyy long time" because your loading the file to your server first and then send it to the client everytime someone is clicking the download link.