开发者

PHP : problem rendering zip file

header("Content-type: application/zip");
$contents=file_get_cont开发者_如何学Cents($the_file);
echo "$contents";
exit;

The file is about 40 MB. But, on downloading, size is only few hundred bytes. Please help!


Try to set Content-Length:

header('Content-Type: application/zip');
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename="file.zip"');


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜