I am looking for a way to allow users to download a file from my site using ajax. The reason why i need to do this is because the files are quite big (50 megs normally). So when the user clicks the download button it actually looks as if the page is not responding because it has to stream the file from my Amazon S3 to the user.
So i need to notify the user that the download is in progress and maybe even give them a progress bar. I have found the following article but i am not really keen on injecting iFrames into my webpage.
Thanks in advance for any help.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I don’t really see how you can allow a user to download a file using ajax. There won’t be any way to get the file to their filesystem from javascript. What’s wrong with targeting the file into an iframe or a new window and letting users manage the download like they are used to using their browser?
Method 2
I have decided to use the IFrame method is there is no other way that works seamlessly enough to make it worth the time.
Method 3
Add a progress bar on your page and Use postback triggers for your updatepanel. It will solve the issue you are facing.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0