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

WBOY
Release: 2016-06-13 11:01:53
Original
996 people have browsed it

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

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

手动设置Header的Content-Length字段

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!