Download part of HTML page as text (PHP)
<p>So I have an 'export' application that arrives the user at an end page with a textarea with lots of text. Now the workflow is to copy and paste that text from the textarea into a file.</p>

<p>The exported code is getting larger, and we want to encourage users to do this more often, so the copy/paste route is no longer desirable. (Not to mention that my xterm->ssh->screen->vi chain doesn't paste 250K characters so well) </p>

<p><strong>So the problem is this: I have a textarea that has exported code in it, and I want to provide a button that is 'Download this Code to a file'</strong></p>

<p>I'm fairly sure that I will have to hit the server again, but I just want to check all my bases. The ways I can think of doing this (sending generated textarea value as a file ot the browser)</p>

<ul>
<li><p>Create a script that receives said text as a POST and sends it back with the right Content Headers. This is no desirable because we would be POSTing 250k, which would be slower than:</p></li>
<li><p>Create a script that regenerates the text area and provide a button the original page that hits the scripts and downloads the file. <em>This is the option I am leaning towards</em></p></li>
<li><p>Use Javascript somehow and perhaps beable to skip the server all together and just send the $('.exported').val() to the browser with the right headers? Not sure how to do this atm.</p></li>
</ul>

<p>So if anyone has suggestions that'd be great, maybe I'm overlooking something. Thanks!</p>

<p>edit: <a href="http://stackoverflow.com/questions/609530/download-textarea-contents-as-a-file-using-only-javascript-no-server-side">http://stackoverflow.com/questions/609530/download-textarea-contents-as-a-file-using-only-javascript-no-server-side</a></p>

<p>This question says the JS route is not possible (probable)</p>
