If the cookie exists, and its value matches the token, hide the "waiting" indicator.Start a timer, and every second or so, look for a cookie named "fileDownloadToken" (or whatever you decide).Submit the download request, and include the token in a GET/POST field.One possible solution uses JavaScript on the client. But I'd rather avoid creating temporary files on the server. But it fails on Internet Explorer and Safari Internet Explorer fires the "load" event, but it doesn't download the file, and Safari downloads the file (with the wrong name and content-type) and doesn't fire the "load" event.Ī different approach might be to call to start the file creation, poll the server until it's ready, and then download the already-created file. This works in Firefox it receives the empty HTML file, fires the "load" event, and then shows the "Save" dialog for the downloadable file. So it would send an empty HTML file, as well as the attached downloadable file.įor example: Content-type: multipart/x-mixed-replace boundary="abcde"Ĭontent-Disposition: attachment filename=foo.fdf One approach I tried is using a multi-part response. But the browser doesn't fire a "load" event in the iframe. I return a " Content-Disposition: attachment" header with the file, which causes the browser to show the "Save" dialog. I listen for a "load" event on the iframe, hoping that it will fire when the download is complete. This is, so I don't replace the entire browser window with the result. I'm requesting a hidden form, which POSTs to the server, and targets a hidden iframe for its results. The problem is, I can't figure out how to detect when the browser has received the file so that I can hide the indicator. It takes a long time to generate, so I'd like to show a "waiting" indicator. I have a page that allows the user to download a dynamically-generated file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |