简体   繁体   中英

Download Image Progress Bar, PHP, Javascript, HTML

I am creating a speed test application which measures a users upload and download speed by timing how long it takes to upload and download various files. At the moment I am using Javascript to download an image from an external server using the following code:

var start_time,end_time;
var download = new Image();
download.onload = function () {
    end_time = (new Date()).getTime();
    download_duration = (end_time - start_time) / 1000;
    finish_download_test();
}
start_time = (new Date()).getTime();
download.src = 'www.fakeimage.com/image.jpg';

This works, however, I would like to display a progress bar whilst the image downloads. I have seen html5 and c# solutions, however, I would like something that is compatible for more browsers (so no html5) and I am using a combo of php and javascript so the c# solution doesnt help either.

Any help would be greatly appreciated, even if it was just a nudge in the right direction.

You can use flash for progress bar. Download files through flash and pass percent to HTML via js or just use flash display.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM