下载速度usign php

时间:2016-04-01 09:25:23

标签: javascript php

我只想知道是否有任何方法我可以拥有像utorrent这样的文件的下载速度,例如usign php或javascript? :) 我在js中尝试过这段代码,但我想要的是实时响应。 ? http://i.imgur.com/APeXWLI.png

<script type="text/javascript">
    //<!--
    var image = 'http://www.hdwallpapers.in/walls/beautiful_makeup_girl_face_art-wide.jpg';
    var size = 5690894 ;//5MB
    var time1 = 0;
    var time2 = 0;
    function start_test_vitesse()
    {
        time1 = new Date();
        time1 = time1.getTime();
        var img = new Image();
        img.src = image+'?'+time1;
        img.onload=end_test_vitesse;
        img.onerror = imagenotfound;
        function imagenotfound() {
            console.log('sorry your internet is down');
            console.log(time1);
            time1=time1 * 100;
        }

        console.log(time1);

    }
    function end_test_vitesse()
    {
        var time2 = new Date();
        time2 = time2.getTime();
        var ms = time2-time1;
        var vitesse = Math.round(size/ms*100)/100;
        document.getElementById('vitesse').value=vitesse+'ko/s';
    }
    //-->
</script> 

0 个答案:

没有答案