PHP Curl realtime getinfo
I'm trying to get Realtime info (Speed, Downloaded, Left) of File Downloads made 开发者_Python百科by a script coded in PHP & Curl.
"curl_getinfo" gives all the required data but it gives it only after the download.
Anyway to get it realtime ?
AFAIK there is no way to do this with cURL. The curl_multi_*
functions will let you make a number of asynchronous requests and check their current state, but only in so much as they will tell you whether they are completed/what their current errorlevel is.
You cannot get information about speed/downloaded/left from cURL. You would have to write your own HTTP request logic using fsockopen() or similar, then you can include logic to update some kind of display somewhere as the request progresses. This does have the disadvantage of being much more difficult to make asynchronous - because of PHP's lack of multi-thread support you would have to use exec()
or pcntl_fork()
and make some kind of horrible IPC architecture.
I have done stuff like this before, and my honest opinion is that it is not worth effort. If you still want to go ahead and do it, I will dig out some of the stuff I used when I did it.
精彩评论