PHP:渲染 zip 文件时出现问题
header("Content-type: application/zip");
$contents=file_get_contents($the_file);
echo "$contents";
exit;
该文件大约 40 MB。但是,下载后,大小只有几百字节。请帮忙!
header("Content-type: application/zip");
$contents=file_get_contents($the_file);
echo "$contents";
exit;
The file is about 40 MB. But, on downloading, size is only few hundred bytes. Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试设置 Content-Length:
Try to set Content-Length:
评论是正确的;这很可能是一条错误消息,通过在文本编辑器中打开文件可以轻松确定。我还想建议您可以使用 readfile 函数来获得更大的效果。请参阅第一个示例,了解一些带有标头的优秀代码,这些代码可以为您提供良好的下载。另外,它会将您的代码缩短一行。 http://php.net/manual/en/function.readfile.php
The comments are correct; it's very likely an error message that will be easily ascertained by opening the file in a text editor. I'd like to also offer that you could use the readfile function to greater effect. See the first example for some good code with headers that gives you a good download. Plus, it'll shorten your code by a line. http://php.net/manual/en/function.readfile.php