Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 views
in Technique[技术] by (71.8m points)

php 实现上传进度 via Session

https://www.pureweber.com/art...
这是php5.4新增的一个功能 使用$_SESSION获取上传进度
但是我按介绍 获得的$_SESSION总为空 根本没有那个键 上传进度就直接100% 求解!

clipboard.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

实际上这个功能可能无法使用,因为文档中的注释有这么一段

Note, this feature doesn't work, when your webserver is runnig PHP via FastCGI. There will be no progress informations in the session array.

如果php是通过FastCGI模式运行的web服务器之后,这个特性无法使用。主要是因为在php获取到客户端的输入之前,上传文件已经在web服务器上完成了,因此总是100%。

可以考虑使用nginx的HttpUploadProgressModule模块。

参考:Does session upload progress work with nginx and php-fpm?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...