How can I create a file in memory for the user to download instead of going through the server?
P粉231112437
2023-08-23 17:55:41
<p>Is there a way to create a text file on the client side and prompt the user to download it without any interaction with the server? </p>
<p>I know I can't write directly to their computer (security, etc.), but can I create the file and prompt them to save? </p>
Simple solution for HTML5 browsers...
use
You can use data URI. Browser support varies; see Wikipedia. Example:
Octet stream is used to force download prompts. Otherwise, it may open in the browser.
For CSV you can use:
TryjsFiddle Demo.