php - curlFile uploading live progressbar
<p>Rrecently I'm creating a telegram bot using telegram Bot API.
My plan is to place a single button in a page for uploading a specific folder's files, to telegram with cUrlFile uploading;
so far, I'm done my work with uploading but my purpose is large-sized files. To do this I need to show user some kind of progress bar that shows user how much MBs or KBs Uploaded.</p>

<p>My upload function is looks something like this:</p>

<pre><code>function sendFile($token,$photosArray,$chatsArray){
    $ch = curl_init('https://api.telegram.org/bot'.$token.'/sendDocument');
    $cfile = new CURLFile(realpath($photosArray['path']),'image/jpg',$photosArray['name']);
    curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION , false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

    foreach($chatsArray as $chatId){
        $data = array('chat_id' =&gt; $chatId, 'document' =&gt; $cfile);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $res=curl_exec($ch);
    }
    return $res;
}
</code></pre>

<p>For now its works but I don't have any idea how can I get uploaded size from this curl and show it to user. of course i mean real-time progress bar.
In other questions I found questions like :
<a href="https://stackoverflow.com/questions/13958303/curl-download-progress-in-php">cURL download progress in PHP</a></p>

<p>But it's not my answer.</p>

<p>Whats I'm looking for is to do this:</p>

<p>1- Click on a button to upload a folder files</p>

<p>2- Upload one file at a time and show a live progress bar to user</p>

<p>3- When upload is completed, start uploading next file and show another progress bar for it and so on.</p>

<p>Is it needs to implemented by AJAX or something else?
I'm pretty new in php so if someone can help me in a simple way I'll all ears.</p>