10

I would like to able to track, purely on the client side, the progress of a file download, especially file download completion.

Is there a JavaScript API that allows me to define a callback upon file download completion?

Ry-
  • 218,210
  • 55
  • 464
  • 476
Randomblue
  • 112,777
  • 145
  • 353
  • 547
  • Whether it's possibly possible depends on a couple of things, but it's probably not possible purely on the client side. You can keep track of what's been sent on the server side, though, and fetch that periodically. – Ry- Aug 18 '12 at 16:20
  • I'm my setup there is no server :0 I'm downloading a local file. – Randomblue Aug 18 '12 at 16:21
  • 3
    There is no server? Where does the file that the client is downloading coming from then? Where is the file hosting your javascript code coming from then? The clouds? AFAIK without the aid of a server what you are trying to achieve is not possible. – Darin Dimitrov Aug 18 '12 at 16:25
  • Why would you download a local file? Anyway, that should be near enough instant. – Ry- Aug 18 '12 at 16:27
  • 3
    @DarinDimitrov: I've found a bug in Chrome that allows me to craft a "file" locally and force Chrome to download it to the downloads folder. I just want to know once the payload has been downloaded. – Randomblue Aug 18 '12 at 16:28
  • You can't know this using pure javascript. There's no API that allows you to do that. Sorry. – Darin Dimitrov Aug 18 '12 at 16:28
  • @Randomblue: Maybe you should report it, instead of exploiting it? – Ry- Aug 18 '12 at 16:35
  • @minitech: There is an ongoing competition to crack Chrome with prizes at hand. – Randomblue Aug 18 '12 at 16:43
  • @DarinDimitrov: I think OP means there is no dedicated server. The project doesn't have a server component. There could be one or more 3rd party servers he has no access to, or it could be downloading from some arbitrary URL... – hippietrail Aug 18 '12 at 16:52

1 Answers1

2

No, this is not possible using pure javascript. There are some techniques though involving using cookies from the server and continuous poll from the client. I've illustrated an example here:

Hide image using Javascript after controller action is complete MVC3

Community
  • 1
  • 1
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928