Search
 
SCRIPT & CODE EXAMPLE
 

PHP

curl download progress bar php

<?php
ob_start();

echo "<pre>";
echo "Loading ...";

ob_flush();
flush();

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://stackoverflow.com");
//curl_setopt($ch, CURLOPT_BUFFERSIZE,128);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, 'progress');
curl_setopt($ch, CURLOPT_NOPROGRESS, false); // needed to make progress function work
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
$html = curl_exec($ch);
curl_close($ch);


function progress($resource,$download_size, $downloaded, $upload_size, $uploaded)
{
    if($download_size > 0)
         echo $downloaded / $download_size  * 100;
    ob_flush();
    flush();
    sleep(1); // just to see effect
}

echo "Done";
ob_flush();
flush();

?>
Comment

PREVIOUS NEXT
Code Example
Php :: php json pretty print and slash 
Php :: match uuid patter laravel regex 
Php :: Function create_function() is deprecated in 
Php :: laravel isset 
Php :: json decode 
Php :: limit query codeiniter 3 
Php :: joomla print query 
Php :: permutation and combination program in php 
Php :: php language is used for 
Php :: Uncaught jquery-numerator requires jQuery to be loaded first wordpress 
Php :: php return associative array 
Php :: create config value file in php 
Php :: laravel longblob migration 
Php :: install composer laravel 
Php :: scirvere su file php 
Php :: laravel update only changed fields 
Php :: laravel digits between does not working 
Php :: php pass 2 date value to javascript 
Php :: twig filter array 
Php :: distinct in laravel 8 
Php :: Invalid datetime format: 1366 Incorrect string value 
Php :: laravel return from db reorder 
Php :: php set time counters inside code meassure 
Php :: how to add files in child theme in theme editor 
Php :: wordpress login programmatically 
Php :: hot to use functions in heredoc 
Php :: bind param php 
Php :: laravel collection find 
Php :: php access multidimensional array by string 
Php :: month php written out 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =