强制下载的 PHP 脚本不起作用
我有一个简单的小 php 代码,它允许我强制用户从我的网站下载视频,而不是在浏览器中播放它
<?php
$path = $_GET['path'];
header('Content-Disposition: attachment; filename=' . basename($path));
readfile($path);
?>
自从我将网站移动到新服务器后,似乎存在权限问题,我收到 403 Forbidden “您无权访问此服务器上的 /download-stream.php。”
php 文件设置为与之前相同的权限 (644)。我不知道为什么现在要这样做。
I had a simple little php code that allowed me to force users to download videos from my site rather than playing it in the browser
<?php
$path = $_GET['path'];
header('Content-Disposition: attachment; filename=' . basename($path));
readfile($path);
?>
Since I moved my site to a new server, there seems to be a permission problem where I am getting a 403 Forbidden "You don't have permission to access /download-stream.php on this server."
the php file is set to the same permissions as before (644). I'm not sure why it's doing this now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通常使用类似的东西来强制下载。如果更改正在下载的文件类型,请记住更改 MIME 类型。
I generally use something like this to force downloads. Remember to change MIME type if you change the type of file being downloaded.
尝试这样的事情:
?>
Try something like this:
?>