Php gets downloaded file size in real time

how to get the size of downloaded files using php
I want to make a real-time download progress. I want to return the downloaded file size to the front end

Php
Mar.09,2021

function filesize ()? Or configure the request header Content-Length?


<?php
$fp = fopen("http://zhangmenshiting.qianqian.com/data2/music/3423b48bd35de901b3512fc1f28cd2e3/567299874/56729985416560064.mp3?xcode=1910cd6f28d29cd260e85653b43f0cf4", "rb");
$dfp = fopen("a.mp3", "wb");
$downloaded = 0;
while (!feof($fp)) {
    $line = fread($fp, 4096);
    $size = strlen($line);
    $downloaded += $size;
    fwrite($dfp, $line, $size);
    printf("%.2fMB\r", $downloaded / 1024 / 1024);
}
fclose($fp);
fclose($dfp);
printf("\n");
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf26b7-31153.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf26b7-31153.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?