title: Server creates file on-the-fly for client to save
body: <p><strong>THE EXAMPLE</strong></p>
  
  <p><strong>1)</strong> User enters in a playlist in a <code>&lt;textarea&gt;</code></p>
  
  <ul>
  <li>C:/music/foo.mp3</li>
  <li>C:/music/bar.mp3</li>
  <li>C:/music/hello.mp3</li>
  </ul>
  
  <p><strong>2)</strong> They click a <em>save</em> button. I send the user's playlist to the server with AJAX.</p>
  
  <p><strong>3)</strong> The server formats the text with PHP in this fashion:</p>
  
  <pre><code>&lt;playlist&gt;
   &lt;item&gt;C:/music/foo.mp3&lt;/item&gt;
   &lt;item&gt;C:/music/bar.mp3&lt;/item&gt;
   &lt;item&gt;C:/music/hello.mp3&lt;/item&gt;
  &lt;/playlist&gt;
  </code></pre>
  
  <p><strong>4)</strong> A file save dialog pops up asking the user to save this formatted text as <em>playlist.m3u</em> on their own harddrive.</p>
  
  <hr>
  
  <p><strong>QUESTIONS</strong></p>
  
  <p><strong>A)</strong> Is it possible to not write a file to the harddrive on the server when generating this m3u file? I don't want millions of files clogging up my server. I suppose PHP can echo out the formatted text and set headers to masquerade as a file. </p>
  
  <p><strong>B)</strong> How do I get the file save dialog to pop up for this <em>on-the-fly</em> file? If it were a real file, I would just have the PHP respond back with the location of the file. Then I would have JS insert a new iFrame with that location. But I don't want to write a file on the server, so I can't do this.</p>
  
  <pre><code>new Ajax.Request(
   'generateM3u.php',
   onSuccess: function(transport) {
    $$('body').first().appendChild(
     new Element(
      'iframe', {
       src: transport.responseText
      }
     )
    );
   }
  );
  </code></pre>