如何从服务器的角度测量php中上传文件(从浏览器到服务器)的时间?
php 是否提供 api 来检查多部分/表单数据上传速率或总持续时间?
我还想知道 PHP 如何了解 IIS 和 php.ini 设置中的各种超时事件?
Does php provide api to check multipart/form-data upload rate , or total duration ?
I also want to know how does PHP knows about various timeout events from IIS and php.ini settings ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不这么认为 - 当 PHP 可以对其执行任何操作时,上传已完成,即 apache 获取上传,然后完成后,将其交给 PHP - 您的脚本在此之前甚至不会运行,所以除非有一种回顾性获取此信息的方法 我认为您不能单独从 PHP 获取它。
获取此数据的常用方法是在客户端使用 flash 或 javascript 或两者兼而有之。
例如,uploadify 或 swfupload 都是很棒的 Flash 上传器,它们为用户提供客户端文件大小限制和上传进度指示。
如果文件上传、进度指示和文件大小限制可以由浏览器本身完成,那就容易多了:(
参考:
http://www.uploadify.com/demos/
http://swfupload.org/
I don't think so - the upload is finished by the time PHP can do anything to it, i.e apache gets the upload then, when finished, hands it to PHP - your script won't even run before that, so unless there is a way to get this information retrospectively I don't think you can get it from PHP alone.
The usual way to get this data is client-side using flash or javascript or both.
For example, uploadify or swfupload are both great flash uploaders that provide client-side filesize limiting and upload progress indication to the user.
It would be so much easier if file uploading, progress indication and filesize limiting could be done by the browser itself :(
Reference:
http://www.uploadify.com/demos/
http://swfupload.org/
对于第一个问题,我相信您可以使用 $_SERVER['REQUEST_TIME'] 变量与
time()
一起自行计算。For the first question, I believe you can use the $_SERVER['REQUEST_TIME'] variable to do the calculation yourself, together with
time()
.您可以检查 $_SERVER 中的一个值以了解请求何时发起。来自 PHP 手册:
因此,您可以将 $_SERVER ['REQUEST_TIME'] 与当前 time() 进行比较,但在 PHP 5.4 普及之前,您的分辨率仅限于 1 秒。
There's a value in $_SERVER you can check to find out when the request was initiated. From the PHP manual:
So you can compare $_SERVER ['REQUEST_TIME'] against the current time() with the proviso that you're limited to a resolution of 1 second until PHP 5.4 becomes widespread.