0

I want to have a progress bar in my page that has an action of DOWNLOAD. In file upload it is possible but in download is it possible also? Can you give me some good reference for this?

I can't find any good reference for this.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Jerielle
  • 7,144
  • 29
  • 98
  • 164
  • you want a progress bar for downloading or uploading? – NewToJS Mar 18 '15 at 03:03
  • I want to have a progress bar when downloading – Jerielle Mar 18 '15 at 03:04
  • 1
    Oh yes, sorry I read your question again. You have pointed out it's possible for uploading but want to know if it's possible for download. Sorry, it's a little early so i didn't read it correct. Good question though! *I think* the only progress you can get is while getting the download to the browser for the browser to start downloading the file. I'm not 100% sure though. – NewToJS Mar 18 '15 at 03:07
  • Did it work for you? – Nevin Madhukar K Mar 19 '15 at 12:09

2 Answers2

0

You can use the progress bar as part of JQuery UI An example is on that page of how to use it for downloads.

trmiller
  • 183
  • 5
  • I know that example but my problem is how to supply the value in that UI. :( – Jerielle Mar 18 '15 at 03:14
  • In general, there will be a lot to consider here. Bandwith speeds, spikes in internet connectivity / slowdown, etc. The way these usually work is to get some estimate ( maybe take the size of the file being downloaded ), use that as a starting point, and use some reasonable guess for how to make the progress bar go forward. It will be your call on how accurate you need / want to be. – trmiller Mar 18 '15 at 03:19
0

Try this: LINK

Stack over flow QN link

This part of the code basically provides the percentile functionality for the value you need for the progress bar.

// progress on transfers from the server to the client (downloads)
function updateProgress (oEvent) {
  if (oEvent.lengthComputable) {
    var percentComplete = oEvent.loaded / oEvent.total;
    // ...
  } else {
    // Unable to compute progress information since the total size is unknown
  }
}

XMLHttpRequest provides the ability to listen to various events that can occur while the request is being processed. This includes periodic progress notifications, error notifications, and so forth.

Community
  • 1
  • 1
Nevin Madhukar K
  • 3,031
  • 2
  • 25
  • 52