imran0 Posted June 24, 2009 Share Posted June 24, 2009 Im using php file_get_contents to download files around 5-10mb and this can take a few minutes. Is it possibly to output the progress one the page as it downloads? Like this: 10%...20%...%30... and so on... Link to comment https://forums.phpfreaks.com/topic/163445-using-file_get_contents-is-there-a-way-to-output-progress/ Share on other sites More sharing options...
derping123 Posted April 17, 2014 Share Posted April 17, 2014 someone please answer this thx Link to comment https://forums.phpfreaks.com/topic/163445-using-file_get_contents-is-there-a-way-to-output-progress/#findComment-1476539 Share on other sites More sharing options...
Psycho Posted April 17, 2014 Share Posted April 17, 2014 This post has over 1,000 views and no one has responded. I would assume that it is not possible - at least not with file_get_contents(). You would likely have to build some process to get the size of the file, then get chunks of the file one at a time so you can calculate the percentage complete. Of course, you can't do this at all with a single PHP script. You have to implement AJAX. A PHP script completes ALL the execution and then returns the result to the page. Link to comment https://forums.phpfreaks.com/topic/163445-using-file_get_contents-is-there-a-way-to-output-progress/#findComment-1476546 Share on other sites More sharing options...
boompa Posted April 18, 2014 Share Posted April 18, 2014 Pretty sure you could do it with cURL and the CURLOPT_PROGRESSFUNCTION callback or the CURLOPT_WRITEFUNCTION callback Link to comment https://forums.phpfreaks.com/topic/163445-using-file_get_contents-is-there-a-way-to-output-progress/#findComment-1476577 Share on other sites More sharing options...
Psycho Posted April 18, 2014 Share Posted April 18, 2014 Pretty sure you could do it with cURL and the CURLOPT_PROGRESSFUNCTION callback or the CURLOPT_WRITEFUNCTION callback Good call. Here's a forum post with a supposed working example: http://stackoverflow.com/questions/1939029/curl-download-progress-in-php-not-working Link to comment https://forums.phpfreaks.com/topic/163445-using-file_get_contents-is-there-a-way-to-output-progress/#findComment-1476596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.