Home  >  Article  >  Backend Development  >  PHP动态生成的资料bytesTotal为0之解决方案

PHP动态生成的资料bytesTotal为0之解决方案

WBOY
WBOYOriginal
2016-06-13 11:01:53894browse

PHP动态生成的文件bytesTotal为0之解决方案
今天做东西突然发现了一个奇怪现象:
使用桩程序(something.php)的时候,进度条一切正常;
布置到服务器上,进度条在某一时刻会有个突变。
调试下来发现在那个特定时刻,其值变为了Infinity,必然是除数bytesTotal为0导致的
经过调查得知,LoaderInfo的bytesTotal是通过Header的Content-Length字段得到的,而php将要动态生成文件的Header里不存在此字段,导致bytesTotal为0.
解决方案是,对php端进行一些预处理,利用

header("Content-Length: ").$content_length;

手动设置Header的Content-Length字段

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn