File download time in PHP/MySQL

后端 未结 3 367
借酒劲吻你
借酒劲吻你 2021-01-29 15:59

I want to find download time in PHP by sending a request to my MySQL server. I have one table with an href link to download the file. If I click download the download time shoul

3条回答
  •  走了就别回头了
    2021-01-29 16:39

    if you need some code you should use filesize and you can evaluate the time to download by doing some calculation, you cannot know the exact time since it depend on the user speed and all the network between your server and the user.

    $filesize = filesize($yourfile);
    $time_for_modem = $filesize * 8 / (56*1024);
    $time_for_adsl = $filesize * 8 / (5*1024*1024);
    $time_for_t3 = $filesize * 8 / (44*1024*1024);
    
    function convertSecondToTime($sec){
      $hour = floor($sec/60)
      return $hour . 'hours and ' . ($sec%60) . 'minutes';
    }
    

    The modem time is for a 56kbps connection, adsl a 5 mbps, T3 44 mbps connection.

提交回复
热议问题