开发者

php echo gzipped file cutting off half way through

I am trying to send gzipped content from the server. I have gzipped a file (get it here), and am trying to echo it out I have set the right headers (I think). The output starts of correctly, but only outputs the first so many lines.

<?php
  $file = file_get_contents('kendo/js/kendo.all.js.gz');
  header('Content-Encoding: gzip');
  head开发者_如何转开发er('Content-Length: '.strlen($file)); # gets the correct filesize of my gzipped file
  echo $file;
?>

Is there something wrong with my method?


Your content length is the length of the gzipped file and not the actual .js file.

Hence the content gets truncated once the length of the gzipped file is reached. Consider using ob_gzhandler

http://php.net/manual/en/function.ob-gzhandler.php


The posted code works - there was another error, I am assuming a browser cache issue - but that has resolved itself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜