Allowing the user to save the file from JavaScript
There are a lot of JavaScript utilities now to allow posting a file in an AJAXified way to t开发者_运维问答he server these days. Is there any utility that allows streaming bytes to the client and download a file? Or dues that still have to be a server-side solution? I'm using .NET.
Thanks.
There's no cross-browser support for accessing the filesystem of the client. You could probably do it with Flash/Java, but a much cleaner solution would be to do it in the server and create a download link for the user.
Brian: What you said about Javascript posting files to a server seems an incomplete statement. Only way javascript can post files to a server is by having the user manually selecting the file he/she wants to upload...
To answer your question...
You should be able to issue some sort of ajax call (to a web service, for example), have the web service read the file into a byte array and return it to the client. On the client side, you would need to assemble the byte array. I would assume you'll have to also set the appropriate response type from the web service call.
This seems to be something like what you are looking for.
精彩评论